Fix: ctf-writer: null dereference in bt_ctf_trace_common_add_stream_class master
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Wed, 18 May 2022 15:49:34 +0000 (11:49 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Thu, 15 Dec 2022 19:46:17 +0000 (14:46 -0500)
commit5c97e2daa9712d1fc3e1df186b25367b1e4cb8b1
tree39f6dcd1b8cde50867a45a4c3f6535880f78909f
parent200e2a8d2be52b46e759bf9f130f817b213c74ff
Fix: ctf-writer: null dereference in bt_ctf_trace_common_add_stream_class

gcc 12.1.0 reports that:
In file included from object-pool.h:38,
                 from clock-class.h:11,
                 from trace.c:27:
In function 'bt_ctf_object_set_parent',
    inlined from 'bt_ctf_object_set_parent' at object.h:102:6,
    inlined from 'bt_ctf_trace_common_add_stream_class' at trace.c:1227:3:
object.h:123:26: warning: null pointer dereference [-Wnull-dereference]
  123 |                 if (child->parent) {
      |                     ~~~~~^~~~~~~~
object.h:123:26: warning: null pointer dereference [-Wnull-dereference]

This can indeed happen if bt_ctf_trace_common_add_stream_class is called
with a nil stream class argument. A null check is added in the error
path.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I313966c1747c3929a46b98af71ba58f607d3c7df
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8084
src/ctf-writer/trace.c
This page took 0.023519 seconds and 4 git commands to generate.