Fix: check for NULL in destroy_pretty_data
In pretty_init, if create_pretty fails, we go to the `error` label and
call destroy_pretty_data. However, destroy_pretty_data does not accept
a NULL pointer.
My understanding is that our "destroy" functions generally check for a
NULL pointer, and return early in that case.
Change destroy_pretty_data to do just that.
Fixes Coverity:
*** CID
1405908: Null pointer dereferences (FORWARD_NULL)
/src/plugins/text/pretty/pretty.c: 588 in pretty_init()
582 bt_self_component_set_data(self_comp, pretty);
583
584 status = BT_COMPONENT_CLASS_INITIALIZE_METHOD_STATUS_OK;
585 goto end;
586
587 error:
>>> CID
1405908: Null pointer dereferences (FORWARD_NULL)
>>> Passing null pointer "pretty" to "destroy_pretty_data", which dereferences it.
588 destroy_pretty_data(pretty);
589
590 end:
591 return status;
Reported-by: Coverity
Change-Id: I65ec6f8b2781c0a3a1166a1e68da1f47dc2da452
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/2178
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Francis Deslauriers <francis.deslauriers@efficios.com>