Revert "Store new malloced value instead." This reverts commit a9693064380ac62005cdd28f22b447902644a72f. As mentioned in [LysLysKOM 20949405] (which probably hasn't been exported correctly to the mailinglist yet): The old code looks correct to me. * Restore s->s->len to the value it had when s->s was allocated (aka s->malloced). * Reallocate s->s with the new (now known) final length. The question does however arise whether the code is correct on realloc failure.