Thanks. It seems quite evident. I will try to set up a scenario to catch it with valgrind though. Do you think it would be easy? I believe you deem it unnecessary, right?
That is certainly true once the modification that I proposed is applied. You need to allocate the space of the string, plus one character for the EOL. However, with the current code you allocate enough memory for the string and then move the pointer one character to the right. It is a simple typo, the brackets are placed incorrectly.
Sent from my phone, please excuse any typos.
Thanks for finding this potential bug and for providing a fix. However, How would you reply to the comment that is written right before the line you mentioned (I am not the author):
/* This doesn't have buffer overflow vulnerabilities, because
we always allocate for enough space before appending. */