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
cute-signatures
Timo Teräs 2021-11-11 11:24:49 +02:00
parent 9d7b4bd253
commit 97e3647e1d
1 changed files with 2 additions and 2 deletions

View File

@ -11,13 +11,13 @@
int apk_pathbuilder_pushb(struct apk_pathbuilder *pb, apk_blob_t b) 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 + b.len + 2 >= ARRAY_SIZE(pb->name)) return -ENAMETOOLONG;
if (i) pb->name[i++] = '/'; if (i) pb->name[i++] = '/';
memcpy(&pb->name[i], b.ptr, b.len); memcpy(&pb->name[i], b.ptr, b.len);
pb->namelen = i + b.len; pb->namelen = i + b.len;
pb->name[pb->namelen] = 0; pb->name[pb->namelen] = 0;
return i; return oldlen;
} }
void apk_pathbuilder_pop(struct apk_pathbuilder *pb, int pos) void apk_pathbuilder_pop(struct apk_pathbuilder *pb, int pos)