From ca400a290a3e98e9f2578d4cbaede87019f2ee94 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Galarneau?= Date: Thu, 27 Jul 2023 12:26:42 -0400 Subject: [PATCH] Fix: lttng-add-context: context type options possible null dereference MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Coverity reports that: ** CID 1518091: Null pointer dereferences (FORWARD_NULL) /src/bin/lttng/commands/add_context.cpp: 820 in destroy_ctx_type(::ctx_type *)( Free application context options only if type->opt isn't null. Signed-off-by: Jérémie Galarneau Change-Id: Icc27d04480c4821ed33127f5baf293510cdb314e --- src/bin/lttng/commands/add_context.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/bin/lttng/commands/add_context.cpp b/src/bin/lttng/commands/add_context.cpp index 550015f17..3a0613bd0 100644 --- a/src/bin/lttng/commands/add_context.cpp +++ b/src/bin/lttng/commands/add_context.cpp @@ -815,11 +815,11 @@ static void destroy_ctx_type(struct ctx_type *type) if (type->opt) { free(type->opt->symbol); - } - if (type->opt->ctx_type == CONTEXT_APP_CONTEXT) { - free(type->opt->u.app_ctx.ctx_name); - free(type->opt->u.app_ctx.provider_name); + if (type->opt->ctx_type == CONTEXT_APP_CONTEXT) { + free(type->opt->u.app_ctx.ctx_name); + free(type->opt->u.app_ctx.provider_name); + } } delete type->opt; -- 2.34.1