tests: include json script shunit2 based testing
[project/libubox.git] / jshn.c
diff --git a/jshn.c b/jshn.c
index 963995191a0f16ffd583a81ccb09378e953377dc..0940b5efd9fa7a75c86190f8f74d9b4abf468201 100644 (file)
--- a/jshn.c
+++ b/jshn.c
@@ -311,7 +311,7 @@ out:
 
 static int usage(const char *progname)
 {
-       fprintf(stderr, "Usage: %s [-n] [-i] -r <message>|-R <file>|-w\n", progname);
+       fprintf(stderr, "Usage: %s [-n] [-i] -r <message>|-R <file>|-o <file>|-p <prefix>|-w\n", progname);
        return 2;
 }
 
@@ -354,7 +354,7 @@ static int jshn_parse_file(const char *path)
                return 3;
        }
 
-       if (!(fbuf = malloc(sb.st_size))) {
+       if (!(fbuf = calloc(1, sb.st_size+1))) {
                fprintf(stderr, "Error allocating memory for %s\n", path);
                close(fd);
                return 3;