summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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);
+
}
/*----------------------------------------------------------------------