Fix: filter: memory leak in filter_parser_ctx
[lttng-tools.git] / src / lib / lttng-ctl / filter / filter-parser.y
index 7c4aebe8db3807ed4a2034bbccd95da625e0544d..d045932b29215492d5a05ce24f66d57dc6bf7b47 100644 (file)
@@ -297,11 +297,16 @@ 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);
 }
 
@@ -588,30 +593,57 @@ shift_expression
                {       $$ = $1;                                        }
        | shift_expression LEFT_OP additive_expression
                {
-                       $$ = make_op_node(parser_ctx, AST_OP_LSHIFT, $1, $3);
+                       $$ = make_op_node(parser_ctx, AST_OP_BIT_LSHIFT, $1, $3);
                }
        | shift_expression RIGHT_OP additive_expression
                {
-                       $$ = make_op_node(parser_ctx, AST_OP_RSHIFT, $1, $3);
+                       $$ = make_op_node(parser_ctx, AST_OP_BIT_RSHIFT, $1, $3);
                }
        ;
 
-relational_expression
+and_expression
        : shift_expression
                {       $$ = $1;                                        }
-       | relational_expression LT_OP shift_expression
+       | and_expression AND_BIN shift_expression
+               {
+                       $$ = make_op_node(parser_ctx, AST_OP_BIT_AND, $1, $3);
+               }
+       ;
+
+exclusive_or_expression
+       : and_expression
+               {       $$ = $1;                                        }
+       | exclusive_or_expression XOR_BIN and_expression
+               {
+                       $$ = make_op_node(parser_ctx, AST_OP_BIT_XOR, $1, $3);
+               }
+       ;
+
+inclusive_or_expression
+       : exclusive_or_expression
+               {       $$ = $1;                                        }
+       | inclusive_or_expression OR_BIN exclusive_or_expression
+               {
+                       $$ = make_op_node(parser_ctx, AST_OP_BIT_OR, $1, $3);
+               }
+       ;
+
+relational_expression
+       : inclusive_or_expression
+               {       $$ = $1;                                        }
+       | relational_expression LT_OP inclusive_or_expression
                {
                        $$ = make_op_node(parser_ctx, AST_OP_LT, $1, $3);
                }
-       | relational_expression GT_OP shift_expression
+       | relational_expression GT_OP inclusive_or_expression
                {
                        $$ = make_op_node(parser_ctx, AST_OP_GT, $1, $3);
                }
-       | relational_expression LE_OP shift_expression
+       | relational_expression LE_OP inclusive_or_expression
                {
                        $$ = make_op_node(parser_ctx, AST_OP_LE, $1, $3);
                }
-       | relational_expression GE_OP shift_expression
+       | relational_expression GE_OP inclusive_or_expression
                {
                        $$ = make_op_node(parser_ctx, AST_OP_GE, $1, $3);
                }
@@ -630,37 +662,10 @@ equality_expression
                }
        ;
 
-and_expression
-       : equality_expression
-               {       $$ = $1;                                        }
-       | and_expression AND_BIN equality_expression
-               {
-                       $$ = make_op_node(parser_ctx, AST_OP_BIT_AND, $1, $3);
-               }
-       ;
-
-exclusive_or_expression
-       : and_expression
-               {       $$ = $1;                                        }
-       | exclusive_or_expression XOR_BIN and_expression
-               {
-                       $$ = make_op_node(parser_ctx, AST_OP_BIT_XOR, $1, $3);
-               }
-       ;
-
-inclusive_or_expression
-       : exclusive_or_expression
-               {       $$ = $1;                                        }
-       | inclusive_or_expression OR_BIN exclusive_or_expression
-               {
-                       $$ = make_op_node(parser_ctx, AST_OP_BIT_OR, $1, $3);
-               }
-       ;
-
 logical_and_expression
-       : inclusive_or_expression
+       : equality_expression
                {       $$ = $1;                                        }
-       | logical_and_expression AND_OP inclusive_or_expression
+       | logical_and_expression AND_OP equality_expression
                {
                        $$ = make_op_node(parser_ctx, AST_OP_AND, $1, $3);
                }
This page took 0.027071 seconds and 4 git commands to generate.