Fix: sessiond: leak of trigger on registration error
[lttng-tools.git] / src / bin / lttng-sessiond / cmd.c
index 505645bf1ce1cb69c864fadb322a3d366e493944..8d36e7192c8deb32a46ca471c5d58dafd5e19d63 100644 (file)
@@ -4459,10 +4459,12 @@ enum lttng_error_code cmd_register_trigger(const struct lttng_credentials *cmd_c
         * reference to the trigger so the caller doesn't have to care if those
         * are distinct instances or not.
         */
         * reference to the trigger so the caller doesn't have to care if those
         * are distinct instances or not.
         */
-       lttng_trigger_get(trigger);
-       *return_trigger = trigger;
-       /* Ownership of trigger was transferred to caller. */
-       trigger = NULL;
+       if (ret_code == LTTNG_OK) {
+               lttng_trigger_get(trigger);
+               *return_trigger = trigger;
+               /* Ownership of trigger was transferred to caller. */
+               trigger = NULL;
+       }
 end:
        return ret_code;
 end_unlock_session_list:
 end:
        return ret_code;
 end_unlock_session_list:
This page took 0.030506 seconds and 4 git commands to generate.