aboutsummaryrefslogtreecommitdiffstats
path: root/text2pcap-scanner.l
diff options
context:
space:
mode:
authorDario Lombardo <lomato@gmail.com>2017-02-21 14:08:27 +0100
committerMichael Mann <mmann78@netscape.net>2017-02-27 00:51:37 +0000
commit513eed6871198d025a45ad70aaa50721857c2095 (patch)
treeb5db549b5e93d779c102057a2ea897162b5cbcaa /text2pcap-scanner.l
parenta08177b00bd07e77baa9db97bd731cb1df9173a8 (diff)
text2pcap: check return values of functions and use a single exit point.
This is going to check every function for success and following patches will free allocated memory in clean_exit. Change-Id: I7ba7a53eae8a37a4c25e56369af20e575c3489fb Reviewed-on: https://code.wireshark.org/review/20225 Petri-Dish: Michael Mann <mmann78@netscape.net> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Michael Mann <mmann78@netscape.net>
Diffstat (limited to 'text2pcap-scanner.l')
-rw-r--r--text2pcap-scanner.l21
1 files changed, 12 insertions, 9 deletions
diff --git a/text2pcap-scanner.l b/text2pcap-scanner.l
index e54e4279a9..1f45f8efda 100644
--- a/text2pcap-scanner.l
+++ b/text2pcap-scanner.l
@@ -88,13 +88,16 @@ eol \r?\n\r?
%%
-{byte} { parse_token(T_BYTE, yytext); }
-{byte_eol} { parse_token(T_BYTE, yytext); parse_token(T_EOL, NULL); }
-{offset} { parse_token(T_OFFSET, yytext); }
-{offset_eol} { parse_token(T_OFFSET, yytext); parse_token(T_EOL, NULL); }
-{mailfwd}{offset} { parse_token(T_OFFSET, yytext+1); }
-{eol} { parse_token(T_EOL, NULL); }
+{byte} { if (parse_token(T_BYTE, yytext) != EXIT_SUCCESS) return EXIT_FAILURE; }
+{byte_eol} { if (parse_token(T_BYTE, yytext) != EXIT_SUCCESS) return EXIT_FAILURE;
+ if (parse_token(T_EOL, NULL) != EXIT_SUCCESS) return EXIT_FAILURE; }
+{offset} { if (parse_token(T_OFFSET, yytext) != EXIT_SUCCESS) return EXIT_FAILURE; }
+{offset_eol} { if (parse_token(T_OFFSET, yytext) != EXIT_SUCCESS) return EXIT_FAILURE;
+ if (parse_token(T_EOL, NULL) != EXIT_SUCCESS) return EXIT_FAILURE; }
+{mailfwd}{offset} { if (parse_token(T_OFFSET, yytext+1) != EXIT_SUCCESS) return EXIT_FAILURE; }
+{eol} { if (parse_token(T_EOL, NULL) != EXIT_SUCCESS) return EXIT_FAILURE; }
[ \t] ; /* ignore whitespace */
-{directive} { parse_token(T_DIRECTIVE, yytext); parse_token(T_EOL, NULL); }
-{comment} { parse_token(T_EOL, NULL); }
-{text} { parse_token(T_TEXT, yytext); }
+{directive} { if (parse_token(T_DIRECTIVE, yytext) != EXIT_SUCCESS) return EXIT_FAILURE;
+ if (parse_token(T_EOL, NULL) != EXIT_SUCCESS) return EXIT_FAILURE; }
+{comment} { if (parse_token(T_EOL, NULL) != EXIT_SUCCESS) return EXIT_FAILURE; }
+{text} { if (parse_token(T_TEXT, yytext) != EXIT_SUCCESS) return EXIT_FAILURE; }