From 185c782861fe6ed224d14293afc57c46ab5e7aed Mon Sep 17 00:00:00 2001 From: Mathieu Desnoyers Date: Thu, 26 Nov 2020 15:50:45 -0500 Subject: [PATCH] Fix: memory leak in apply_context_reloc Fixes commit b77aaa1b8edf2 ("Decouple `struct lttng_session` from filter code") lttng_ust_add_app_context_to_ctx_rcu should be able to update the session ctx field and not only the local ctx pointer. Signed-off-by: Mathieu Desnoyers Change-Id: I1bfdc7a1a2b6f9c579206e996572e36bf30d60e7 --- liblttng-ust/lttng-bytecode.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/liblttng-ust/lttng-bytecode.c b/liblttng-ust/lttng-bytecode.c index 30d3cbd1..a30dd182 100644 --- a/liblttng-ust/lttng-bytecode.c +++ b/liblttng-ust/lttng-bytecode.c @@ -298,21 +298,21 @@ int apply_context_reloc(struct bytecode_runtime *runtime, struct load_op *op; struct lttng_ctx_field *ctx_field; int idx; - struct lttng_ctx *ctx = *runtime->p.pctx; + struct lttng_ctx **pctx = runtime->p.pctx; dbg_printf("Apply context reloc: %u %s\n", reloc_offset, context_name); /* Get context index */ - idx = lttng_get_context_index(ctx, context_name); + idx = lttng_get_context_index(*pctx, context_name); if (idx < 0) { if (lttng_context_is_app(context_name)) { int ret; ret = lttng_ust_add_app_context_to_ctx_rcu(context_name, - &ctx); + pctx); if (ret) return ret; - idx = lttng_get_context_index(ctx, context_name); + idx = lttng_get_context_index(*pctx, context_name); if (idx < 0) return -ENOENT; } else { @@ -324,7 +324,7 @@ int apply_context_reloc(struct bytecode_runtime *runtime, return -EINVAL; /* Get context return type */ - ctx_field = &ctx->fields[idx]; + ctx_field = &(*pctx)->fields[idx]; op = (struct load_op *) &runtime->code[reloc_offset]; switch (bytecode_op) { -- 2.34.1