forked from osmocom/wireshark
dfilter: Free a scanner string earlier
This commit is contained in:
parent
15051c0671
commit
82ced8965c
|
@ -161,23 +161,14 @@ static int set_lval_str(int token, const char *token_value);
|
|||
|
||||
[rR]{0,1}\042 {
|
||||
/* start quote of a quoted string */
|
||||
/* The example of how to scan for strings was taken from
|
||||
the flex 2.5.4 manual, from the section "Start Conditions".
|
||||
See:
|
||||
http://www.gnu.org/software/flex/manual/html_node/flex_11.html */
|
||||
|
||||
/*
|
||||
* The example of how to scan for strings was taken from
|
||||
* the flex manual, from the section "Start Conditions".
|
||||
* See: https://westes.github.io/flex/manual/Start-Conditions.html
|
||||
*/
|
||||
BEGIN(DQUOTE);
|
||||
/* A previous filter that failed to compile due to
|
||||
a missing end quote will have left quoted_string set
|
||||
to something. Clear it now that we are starting
|
||||
a new quoted string. */
|
||||
if (yyextra->quoted_string) {
|
||||
g_string_free(yyextra->quoted_string, TRUE);
|
||||
/* Don't set quoted_string to NULL, as we
|
||||
do in other quoted_string-cleanup code, as we're
|
||||
about to set it in the next line. */
|
||||
}
|
||||
yyextra->quoted_string = g_string_new("");
|
||||
|
||||
if (yytext[0] == 'r' || yytext[0] == 'R') {
|
||||
/*
|
||||
* This is a raw string (like in Python). Rules: 1) The two
|
||||
|
@ -197,11 +188,8 @@ static int set_lval_str(int token, const char *token_value);
|
|||
|
||||
<DQUOTE><<EOF>> {
|
||||
/* unterminated string */
|
||||
/* The example of how to handle unclosed strings was taken from
|
||||
the flex 2.5.4 manual, from the section "End-of-file rules".
|
||||
See:
|
||||
http://www.gnu.org/software/flex/manual/html_node/flex_13.html */
|
||||
|
||||
g_string_free(yyextra->quoted_string, TRUE);
|
||||
yyextra->quoted_string = NULL;
|
||||
dfilter_fail(yyextra->dfw, "The final quote was missing from a quoted string.");
|
||||
return SCAN_FAILED;
|
||||
}
|
||||
|
@ -275,32 +263,14 @@ static int set_lval_str(int token, const char *token_value);
|
|||
|
||||
\047 {
|
||||
/* start quote of a quoted character value */
|
||||
/* The example of how to scan for strings was taken from
|
||||
the Flex manual, from the section "Start Conditions".
|
||||
See:
|
||||
http://flex.sourceforge.net/manual/Start-Conditions.html#Start-Conditions */
|
||||
|
||||
BEGIN(SQUOTE);
|
||||
/* A previous filter that failed to compile due to
|
||||
a missing end quote will have left quoted_string set
|
||||
to something. Clear it now that we are starting
|
||||
a new quoted string. */
|
||||
if (yyextra->quoted_string) {
|
||||
g_string_free(yyextra->quoted_string, TRUE);
|
||||
/* Don't set quoted_string to NULL, as we
|
||||
do in other quoted_string-cleanup code, as we're
|
||||
about to set it in the next line. */
|
||||
}
|
||||
yyextra->quoted_string = g_string_new("'");
|
||||
}
|
||||
|
||||
<SQUOTE><<EOF>> {
|
||||
/* unterminated character value */
|
||||
/* The example of how to handle unclosed strings was taken from
|
||||
the Flex manual, from the section "End-of-file rules".
|
||||
See:
|
||||
http://flex.sourceforge.net/manual/EOF.html#EOF.html */
|
||||
|
||||
g_string_free(yyextra->quoted_string, TRUE);
|
||||
yyextra->quoted_string = NULL;
|
||||
dfilter_fail(yyextra->dfw, "The final quote was missing from a character constant.");
|
||||
return SCAN_FAILED;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue