From 97e3647e1d1684724d75daeda56e1fcb42fa2e7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timo=20Ter=C3=A4s?= Date: Thu, 11 Nov 2021 11:24:49 +0200 Subject: [PATCH] pathbuilder: fix push return value Always return the original length; not the one with trailing '/' amended. fixes c60b7424 "optimize apk_pathbuilder_pop to get the old length" ref #10784 --- src/pathbuilder.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pathbuilder.c b/src/pathbuilder.c index 277d0c2..3f25cf8 100644 --- a/src/pathbuilder.c +++ b/src/pathbuilder.c @@ -11,13 +11,13 @@ int apk_pathbuilder_pushb(struct apk_pathbuilder *pb, apk_blob_t b) { - size_t i = pb->namelen; + size_t oldlen = pb->namelen, i = pb->namelen; if (i + b.len + 2 >= ARRAY_SIZE(pb->name)) return -ENAMETOOLONG; if (i) pb->name[i++] = '/'; memcpy(&pb->name[i], b.ptr, b.len); pb->namelen = i + b.len; pb->name[pb->namelen] = 0; - return i; + return oldlen; } void apk_pathbuilder_pop(struct apk_pathbuilder *pb, int pos)