Add NUL terminator to allocated memory.

I zeroed out the allocated memory block so that both partial and full
reads are NUL-terminated.