fix errors flagged by clang static analyzer

builtin.c: bug - free of uninitialized jv
compile.c: missing assertion
jq_test.c: buggy logic / unreachable code
jv.c: missing assertion
jv_alloc.c: false positive - intentional read of uninitialized memory
jv_file.c: dead code
This commit is contained in:
David Tolnay authored and Nicolas Williams committed 2015-06-20 16:08:56 -05:00
1 parent 7811ef1e17
commit 4a316fbb5a
6 files changed
+12 -9

No files matched your search

+6 -3
View File
@@ -87,14 +87,15 @@ static void run_jq_tests(jv lib_dirs, FILE *testdata) {
if (must_fail) {
jq_set_error_cb(jq, NULL, NULL);
must_fail = 0;
check_msg = 0;
if (!fgets(buf, sizeof(buf), testdata)) { invalid++; break; }
lineno++;
if (buf[strlen(buf)-1] == '\n') buf[strlen(buf)-1] = 0;
if (compiled) {
printf("*** Test program compiled that should not have at line %u: %s\n", lineno, prog);
invalid++; continue;
must_fail = 0;
check_msg = 0;
invalid++;
continue;
}
if (check_msg && strcmp(buf, err_msg.buf) != 0) {
printf("*** Erroneous test program failed with wrong message (%s) at line %u: %s\n", err_msg.buf, lineno, prog);
@@ -102,6 +103,8 @@ static void run_jq_tests(jv lib_dirs, FILE *testdata) {
} else {
passed++;
}
must_fail = 0;
check_msg = 0;
continue;
}