From 4a316fbb5a1119ebb74b271129d563fd284315bc Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Fri, 19 Jun 2015 10:33:35 -0700 Subject: 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 --- builtin.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'builtin.c') diff --git a/builtin.c b/builtin.c index 6dfb35d1..7cc2b958 100644 --- a/builtin.c +++ b/builtin.c @@ -671,8 +671,7 @@ static jv f_match(jq_state *jq, jv input, jv regex, jv modifiers, jv testmode) { return jv_invalid_with_msg(jv_string_concat(jv_string("Regex failure: "), jv_string((char*)ebuf))); } - if (!test) - result = jv_array(); + result = test ? jv_false() : jv_array(); const char *input_string = jv_string_value(input); const UChar* start = (const UChar*)jv_string_value(input); const unsigned long length = jv_string_length_bytes(jv_copy(input)); @@ -760,8 +759,6 @@ static jv f_match(jq_state *jq, jv input, jv regex, jv modifiers, jv testmode) { start = (const UChar*)(input_string+region->end[0]); onig_region_free(region,0); } else if (onigret == ONIG_MISMATCH) { - if (test) - result = jv_false(); break; } else { /* Error */ UChar ebuf[ONIG_MAX_ERROR_MESSAGE_LEN]; -- cgit v1.2.3