Fix: string leak when processing of client message fails
[lttng-tools.git] / src / bin / lttng-sessiond / main.c
index 7a8b5ae42dcfedb4c7af6a159997d3eaa98dd02f..c8989113a2e9b701f460b92ad189b7e2a3b60189 100644 (file)
@@ -3369,12 +3369,16 @@ skip_domain:
                                ret = -LTTNG_ERR_NOMEM;
                                goto error;
                        }
+                       cmd_ctx->lsm->u.context.ctx.u.app_ctx.provider_name =
+                                       provider_name;
 
                        context_name = zmalloc(context_name_len + 1);
                        if (!context_name) {
                                ret = -LTTNG_ERR_NOMEM;
                                goto error_add_context;
                        }
+                       cmd_ctx->lsm->u.context.ctx.u.app_ctx.ctx_name =
+                                       context_name;
 
                        ret = lttcomm_recv_unix_sock(sock, provider_name,
                                        provider_name_len);
@@ -3387,10 +3391,6 @@ skip_domain:
                        if (ret < 0) {
                                goto error_add_context;
                        }
-                       cmd_ctx->lsm->u.context.ctx.u.app_ctx.provider_name =
-                                       provider_name;
-                       cmd_ctx->lsm->u.context.ctx.u.app_ctx.ctx_name =
-                                       context_name;
                }
 
                /*
This page took 0.023527 seconds and 4 git commands to generate.