summaryrefslogtreecommitdiffstats
path: root/src/scanner.l
diff options
context:
space:
mode:
authorEric Leblond <eric@regit.org>2017-07-11 00:32:54 +0200
committerPablo Neira Ayuso <pablo@netfilter.org>2017-07-17 17:20:34 +0200
commit4223878982af3efd924691bb9721cdf32862d0b7 (patch)
treeae4de085eb2478f2d8fd2a669685e39a6f3030cc /src/scanner.l
parent0fdb267c521ea8717fcd5cd1ddf38fc5b0e9c725 (diff)
scanner: free filename when destroying scanner
To be able to do so we duplicate the name in the indesc if it is set. Signed-off-by: Eric Leblond <eric@regit.org> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'src/scanner.l')
-rw-r--r--src/scanner.l11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/scanner.l b/src/scanner.l
index 86a03f3b..7d5437f1 100644
--- a/src/scanner.l
+++ b/src/scanner.l
@@ -835,6 +835,7 @@ void scanner_push_buffer(void *scanner, const struct input_descriptor *indesc,
state->indesc = &state->indescs[state->indesc_idx++];
memcpy(state->indesc, indesc, sizeof(*state->indesc));
state->indesc->data = buffer;
+ state->indesc->name = NULL;
b = yy_scan_string(buffer, scanner);
assert(b != NULL);
@@ -858,9 +859,15 @@ void scanner_destroy(struct parser_state *scanner)
{
struct parser_state *state = yyget_extra(scanner);
- /* Can't free indesc name - locations might still be in use */
- while (state->indesc_idx--)
+ do {
+ struct input_descriptor *inpdesc =
+ &state->indescs[state->indesc_idx];
+ if (inpdesc && inpdesc->name) {
+ xfree(inpdesc->name);
+ inpdesc->name = NULL;
+ }
yypop_buffer_state(scanner);
+ } while (state->indesc_idx--);
yylex_destroy(scanner);
}