Fix: avoid freeing invalid ptr in filter bytecode
authorDavid Goulet <dgoulet@efficios.com>
Mon, 14 Jul 2014 18:32:10 +0000 (14:32 -0400)
committerDavid Goulet <dgoulet@efficios.com>
Mon, 14 Jul 2014 18:32:28 +0000 (14:32 -0400)
Reported-by: Jonathan Rajotte <jonathan.r.julien@gmail.com>
Signed-off-by: David Goulet <dgoulet@efficios.com>
src/lib/lttng-ctl/filter/filter-visitor-generate-bytecode.c
src/lib/lttng-ctl/lttng-ctl.c

index 8c6dc96ff236520de23ea0efa7ee7b37f1c20784..7d62757477febbcddd0a88e8f4524d74c74682a9 100644 (file)
@@ -520,10 +520,15 @@ int recursive_visit_gen_bytecode(struct filter_parser_ctx *ctx,
 LTTNG_HIDDEN
 void filter_bytecode_free(struct filter_parser_ctx *ctx)
 {
-       free(ctx->bytecode);
-       ctx->bytecode = NULL;
-       free(ctx->bytecode_reloc);
-       ctx->bytecode_reloc = NULL;
+       if (ctx->bytecode) {
+               free(ctx->bytecode);
+               ctx->bytecode = NULL;
+       }
+
+       if (ctx->bytecode_reloc) {
+               free(ctx->bytecode_reloc);
+               ctx->bytecode_reloc = NULL;
+       }
 }
 
 LTTNG_HIDDEN
index 01572dc94dc2aa873d58ece215734a0ffcb8485c..a385d1b9a0a540f589d843b11a78325975cc4aa9 100644 (file)
@@ -851,7 +851,6 @@ static int generate_filter(char *filter_expression,
        return 0;
 
 parse_error:
-       filter_bytecode_free(ctx);
        filter_ir_free(ctx);
        filter_parser_ctx_free(ctx);
 filter_alloc_error:
This page took 0.027167 seconds and 4 git commands to generate.