From 9c62ea46cd5ece0405dbf58fa937807b9eeae5dd Mon Sep 17 00:00:00 2001 From: Hadriel Kaplan Date: Tue, 25 Feb 2014 10:44:39 -0500 Subject: Fix text2pcap.c: Argument with 'nonnull' attribute passed null (clang analyzer) Clang scan analysis reports API error for text2pcap.c. Change-Id: Ie0861d75888e258d9fd928d5d7441e1e3a8279ba Reviewed-on: https://code.wireshark.org/review/367 Reviewed-by: Evan Huus Reviewed-by: Anders Broman --- text2pcap.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'text2pcap.c') diff --git a/text2pcap.c b/text2pcap.c index 95be74de8c..3b57476e2e 100644 --- a/text2pcap.c +++ b/text2pcap.c @@ -1182,6 +1182,7 @@ parse_token (token_t token, char *str) /* ----- Waiting for new packet -------------------------------------------*/ case INIT: + if (!str && token != T_EOL) goto fail_null_str; switch (token) { case T_TEXT: append_to_preamble(str); @@ -1211,6 +1212,7 @@ parse_token (token_t token, char *str) /* ----- Processing packet, start of new line -----------------------------*/ case START_OF_LINE: + if (!str && token != T_EOL) goto fail_null_str; switch (token) { case T_TEXT: append_to_preamble(str); @@ -1264,6 +1266,7 @@ parse_token (token_t token, char *str) case T_BYTE: /* Record the byte */ state = READ_BYTE; + if (!str) goto fail_null_str; write_byte(str); break; case T_TEXT: @@ -1368,6 +1371,12 @@ parse_token (token_t token, char *str) if (debug >= 2) fprintf(stderr, ", %s)\n", state_str[state]); + return; + +fail_null_str: + fprintf(stderr, "FATAL ERROR: got NULL str pointer in state (%d)", state); + exit(1); + } /*---------------------------------------------------------------------- -- cgit v1.2.1