From: Simon Marchi Date: Sun, 22 Jan 2023 19:35:32 +0000 (-0500) Subject: lib: add null checks before "casting" to "base class" X-Git-Url: http://git.efficios.com/?a=commitdiff_plain;h=6ef39fe95fc5956397585fedb4424376b08d8d0e;hp=6ef39fe95fc5956397585fedb4424376b08d8d0e;p=babeltrace.git lib: add null checks before "casting" to "base class" With -fsanitize=undefined, I see: /home/simark/src/babeltrace/src/lib/error.c:526:2: runtime error: member access within null pointer of type 'struct bt_error_cause_component_actor' This is because doing `&cause->base` is undefined behavior if cause is NULL. Add NULL checks around these expressions, when cause may be NULL. Change-Id: Ie11273a24aa17a96bfccf10b121838e48c61984b Signed-off-by: Simon Marchi Reviewed-on: https://review.lttng.org/c/babeltrace/+/9584 Tested-by: jenkins Reviewed-by: Jérémie Galarneau ---