Make sure to NULL terminate text for unowned buffers

This fixes the case where the stream gets passed in a valid buffer
(i.e. unowned) which we cannot know is null terminated or not.