aboutsummaryrefslogtreecommitdiffstats
path: root/text2pcap.c
diff options
context:
space:
mode:
authorHadriel Kaplan <hadrielk@yahoo.com>2014-02-25 10:44:39 -0500
committerAnders Broman <a.broman58@gmail.com>2014-03-02 02:56:17 +0000
commit9c62ea46cd5ece0405dbf58fa937807b9eeae5dd (patch)
treefc3de749c5d536d58d9a026f399bef2652f6b0fa /text2pcap.c
parent111c0778bdea2cb2b39d2974af580a5c18fa7a34 (diff)
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 <eapache@gmail.com> Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'text2pcap.c')
-rw-r--r--text2pcap.c9
1 files changed, 9 insertions, 0 deletions
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);
+
}
/*----------------------------------------------------------------------