Fixing "buffer not null terminated"-bug