Fix: filter: memory leak in filter_parser_ctx
[lttng-tools.git] / src / lib / lttng-ctl / filter / filter-parser.y
index e9c2e6aabe9c1ad25891052f2af76381b2d1202f..5853510a202ebde8f1dc5d9f092e9a6cc00c66ff 100644 (file)
@@ -4,20 +4,9 @@
  *
  * LTTng filter expression parser
  *
- * Copyright 2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ * Copyright 2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
  *
- * This library is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License, version 2.1 only,
- * as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this library; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ * SPDX-License-Identifier: LGPL-2.1-only
  *
  * Grammar inspired from http://www.quut.com/c/ANSI-C-grammar-y.html
  */
@@ -104,7 +93,7 @@ end:
  * gsrc will be garbage collected immediately, and gstr might be.
  * Should only be used to append characters to a string literal or constant.
  */
-LTTNG_HIDDEN
+static
 struct gc_string *gc_string_append(struct filter_parser_ctx *parser_ctx,
                                   struct gc_string *gstr,
                                   struct gc_string *gsrc)
@@ -196,17 +185,11 @@ static struct filter_node *make_op_node(struct filter_parser_ctx *scanner,
        return node;
 }
 
-LTTNG_HIDDEN
+static
 void yyerror(struct filter_parser_ctx *parser_ctx, yyscan_t scanner, const char *str)
 {
        fprintf(stderr, "error %s\n", str);
 }
-LTTNG_HIDDEN
-int yywrap(void)
-{
-       return 1;
-} 
 
 #define parse_error(parser_ctx, str)                           \
 do {                                                           \
@@ -297,16 +280,29 @@ void filter_parser_ctx_free(struct filter_parser_ctx *parser_ctx)
 {
        int ret;
 
-       free_strings(&parser_ctx->allocated_strings);
-       filter_ast_free(parser_ctx->ast);
        ret = yylex_destroy(parser_ctx->scanner);
        if (ret)
                fprintf(stderr, "yylex_destroy error\n");
+
+       filter_ast_free(parser_ctx->ast);
+       free_strings(&parser_ctx->allocated_strings);
+       filter_ir_free(parser_ctx);
+       free(parser_ctx->bytecode);
+       free(parser_ctx->bytecode_reloc);
+
        free(parser_ctx);
 }
 
 %}
 
+%code provides
+{
+#include "common/macros.h"
+
+LTTNG_HIDDEN
+void setstring(struct filter_parser_ctx *parser_ctx, YYSTYPE *lvalp, const char *src);
+}
+
 %define api.pure
        /* %locations */
 %parse-param {struct filter_parser_ctx *parser_ctx}
This page took 0.025804 seconds and 4 git commands to generate.