From c87468e926f75fef29e5f6c997d8baa28d8bc8a9 Mon Sep 17 00:00:00 2001 From: Daniel Stone Date: Tue, 29 May 2012 16:15:07 +0100 Subject: [PATCH] stringcomp: NULL-terminate string Signed-off-by: Daniel Stone --- test/stringcomp.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/test/stringcomp.c b/test/stringcomp.c index d05c7d4..a079346 100644 --- a/test/stringcomp.c +++ b/test/stringcomp.c @@ -55,7 +55,7 @@ int main(int argc, char *argv[]) fd = open(path, O_RDONLY); assert(fd >= 0); assert(fstat(fd, &info) == 0); - as_string = malloc(info.st_size); + as_string = malloc(info.st_size + 1); assert(as_string); remaining = info.st_size; @@ -66,8 +66,7 @@ int main(int argc, char *argv[]) } assert(remaining == 0); - - fprintf(stderr, "trying to parse this:\n%s\n", as_string); + as_string[info.st_size] = '\0'; keymap = xkb_map_new_from_string(ctx, as_string, XKB_KEYMAP_FORMAT_TEXT_V1, 0); -- 2.34.1