From: David Goulet Date: Mon, 14 Jul 2014 18:32:10 +0000 (-0400) Subject: Fix: avoid freeing invalid ptr in filter bytecode X-Git-Tag: v2.6.0-rc1~145 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=3f0c88379cfbbbec84641e13b21f290a563f8729;p=lttng-tools.git Fix: avoid freeing invalid ptr in filter bytecode Reported-by: Jonathan Rajotte Signed-off-by: David Goulet --- diff --git a/src/lib/lttng-ctl/filter/filter-visitor-generate-bytecode.c b/src/lib/lttng-ctl/filter/filter-visitor-generate-bytecode.c index 8c6dc96ff..7d6275747 100644 --- a/src/lib/lttng-ctl/filter/filter-visitor-generate-bytecode.c +++ b/src/lib/lttng-ctl/filter/filter-visitor-generate-bytecode.c @@ -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 diff --git a/src/lib/lttng-ctl/lttng-ctl.c b/src/lib/lttng-ctl/lttng-ctl.c index 01572dc94..a385d1b9a 100644 --- a/src/lib/lttng-ctl/lttng-ctl.c +++ b/src/lib/lttng-ctl/lttng-ctl.c @@ -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: