While "browsing" some code (what else to do with your spare time ;-), I find (not committed yet):
commit e8716b0a9313e5c32b4dbf1d9c6246cad5a6b3b2 Author: Stephen R. van den Berg srb@cuci.nl Date: Mon Sep 1 11:31:36 2014 +0200
Store new malloced value instead.
diff --git a/src/stralloc.c b/src/stralloc.c index 7cd709c..6ca0a02 100644 --- a/src/stralloc.c +++ b/src/stralloc.c @@ -3221,10 +3221,8 @@ PMOD_EXPORT void free_string_builder(struct string_builder *s) PMOD_EXPORT struct pike_string *finish_string_builder(struct string_builder *s) { ptrdiff_t len = s->s->len; - if (len != s->malloced) { - s->s->len = s->malloced; - s->s = realloc_unlinked_string(s->s, len); - } + if (len != s->malloced) + s->s = realloc_unlinked_string(s->s, s->malloced = len); else /* Ensure NUL-termination */ low_set_index(s->s,s->s->len,0);
Am I just reading this wrong, or was the len/malloced assignment the wrong way around? And if yes, does this have any noticeable impact on the rest of the system?