Created attachment 728337 [details]
correctly calculate string buffer size
The code uses .text_length to determine size of buffer, but uses .text as the
data to append, and .text_length is not the length of the .text string.
Use .text to calculate the correct size of the buffer.