Fix: ctf-writer: null dereference in bt_ctf_trace_common_add_stream_class
[babeltrace.git] / src / ctf-writer / trace.c
index c31042fec58d48587d0f3b30f4a4fd3a9384eac3..c6c5f8bd520e9c33710294941feb5e6ba79145c9 100644 (file)
@@ -1,30 +1,15 @@
 /*
+ * SPDX-License-Identifier: MIT
+ *
  * Copyright 2013, 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
  * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
  */
 
 #define BT_LOG_TAG "CTF-WRITER/TRACE"
 #include "logging.h"
 
 #include <inttypes.h>
+#include <stdbool.h>
 #include <stdint.h>
 #include <stdlib.h>
 #include <string.h>
@@ -1239,7 +1224,9 @@ int bt_ctf_trace_common_add_stream_class(struct bt_ctf_trace_common *trace,
 
 end:
        if (ret) {
-               bt_ctf_object_set_parent(&stream_class->base, NULL);
+               if (stream_class) {
+                       bt_ctf_object_set_parent(&stream_class->base, NULL);
+               }
 
                if (ec_validation_outputs) {
                        for (i = 0; i < event_class_count; i++) {
This page took 0.024302 seconds and 4 git commands to generate.