Fix: lttng: uninitialized pointer free'd when no sessiond is present
[lttng-tools.git] / src / common / session-consumed-size.c
index 6ff1c24866cd93da6c02bb60920a27004f027bce..dfb72632e26fed863c7463848b354655f3327498 100644 (file)
@@ -1,18 +1,8 @@
 /*
 /*
- * Copyright (C) 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ * Copyright (C) 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com>
  *
  *
- * This library is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License, version 2.1 only,
- * as published by the Free Software Foundation.
+ * SPDX-License-Identifier: LGPL-2.1-only
  *
  *
- * This library is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
- * for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this library; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
 #include <lttng/condition/condition-internal.h>
  */
 
 #include <lttng/condition/condition-internal.h>
@@ -59,11 +49,11 @@ bool lttng_condition_session_consumed_size_validate(
        consumed = container_of(condition, struct lttng_condition_session_consumed_size,
                        parent);
        if (!consumed->session_name) {
        consumed = container_of(condition, struct lttng_condition_session_consumed_size,
                        parent);
        if (!consumed->session_name) {
-               ERR("Invalid buffer condition: a target session name must be set.");
+               ERR("Invalid session consumed size condition: a target session name must be set.");
                goto end;
        }
        if (!consumed->consumed_threshold_bytes.set) {
                goto end;
        }
        if (!consumed->consumed_threshold_bytes.set) {
-               ERR("Invalid session condition: a threshold must be set.");
+               ERR("Invalid session consumed size condition: a threshold must be set.");
                goto end;
        }
 
                goto end;
        }
 
@@ -136,8 +126,9 @@ bool lttng_condition_session_consumed_size_is_equal(const struct lttng_condition
                }
        }
 
                }
        }
 
-       if ((a->session_name && !b->session_name) ||
-                       (!a->session_name && b->session_name)) {
+       assert(a->session_name);
+       assert(b->session_name);
+       if (strcmp(a->session_name, b->session_name)) {
                goto end;
        }
 
                goto end;
        }
 
@@ -198,7 +189,7 @@ ssize_t init_condition_from_buffer(struct lttng_condition *condition,
        status = lttng_condition_session_consumed_size_set_threshold(condition,
                        condition_comm->consumed_threshold_bytes);
        if (status != LTTNG_CONDITION_STATUS_OK) {
        status = lttng_condition_session_consumed_size_set_threshold(condition,
                        condition_comm->consumed_threshold_bytes);
        if (status != LTTNG_CONDITION_STATUS_OK) {
-               ERR("Failed to initialize session consumed condition threshold");
+               ERR("Failed to initialize session consumed size condition threshold");
                ret = -1;
                goto end;
        }
                ret = -1;
                goto end;
        }
@@ -213,7 +204,7 @@ ssize_t init_condition_from_buffer(struct lttng_condition *condition,
        status = lttng_condition_session_consumed_size_set_session_name(condition,
                        session_name);
        if (status != LTTNG_CONDITION_STATUS_OK) {
        status = lttng_condition_session_consumed_size_set_session_name(condition,
                        session_name);
        if (status != LTTNG_CONDITION_STATUS_OK) {
-               ERR("Failed to set buffer consumed session name");
+               ERR("Failed to set session consumed size condition's session name");
                ret = -1;
                goto end;
        }
                ret = -1;
                goto end;
        }
@@ -401,7 +392,7 @@ end:
 
 static
 int lttng_evaluation_session_consumed_size_serialize(
 
 static
 int lttng_evaluation_session_consumed_size_serialize(
-               struct lttng_evaluation *evaluation,
+               const struct lttng_evaluation *evaluation,
                struct lttng_dynamic_buffer *buf)
 {
        struct lttng_evaluation_session_consumed_size *consumed;
                struct lttng_dynamic_buffer *buf)
 {
        struct lttng_evaluation_session_consumed_size *consumed;
This page took 0.024838 seconds and 5 git commands to generate.