Commit c87468e926f75fef29e5f6c997d8baa28d8bc8a9

Daniel Stone 2012-05-29T16:15:07

stringcomp: NULL-terminate string Signed-off-by: Daniel Stone <daniel@fooishbar.org>

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);