Copyright ownership transfer
[lttng-tools.git] / src / lib / lttng-ctl / lttng-ctl.cpp
index 63841df403f249d5aeb681ce81a0ec671b7d4242..684cf466984eabc6fdd973a24a581f7cabaf28e9 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Linux Trace Toolkit Control Library
  *
- * Copyright (C) 2011 David Goulet <david.goulet@polymtl.ca>
+ * Copyright (C) 2011 EfficiOS Inc.
  * Copyright (C) 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
  *
  * SPDX-License-Identifier: LGPL-2.1-only
@@ -2102,6 +2102,12 @@ int lttng_list_sessions(struct lttng_session **out_sessions)
 
        memset(&lsm, 0, sizeof(lsm));
        lsm.cmd_type = LTTNG_LIST_SESSIONS;
+       /*
+        * Initialize out_sessions to NULL so it is initialized when
+        * lttng_list_sessions returns 0, thus allowing *out_sessions to
+        * be subsequently freed.
+        */
+       *out_sessions = NULL;
        ret = lttng_ctl_ask_sessiond(&lsm, (void**) &sessions);
        if (ret <= 0) {
                goto end;
@@ -2114,7 +2120,6 @@ int lttng_list_sessions(struct lttng_session **out_sessions)
        if (ret % session_size) {
                ret = -LTTNG_ERR_UNK;
                free(sessions);
-               *out_sessions = NULL;
                goto end;
        }
        session_count = (size_t) ret / session_size;
This page took 0.023506 seconds and 4 git commands to generate.