Fix: check for NULL in destroy_pretty_data
authorSimon Marchi <simon.marchi@efficios.com>
Sun, 13 Oct 2019 03:11:57 +0000 (23:11 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Thu, 17 Oct 2019 16:13:27 +0000 (12:13 -0400)
commit8a646afb27e079d7f9b556b9200a4a1808da98d8
treef0dea11400e2958cfde589389ebe822487aaac0c
parent0b6986b4940800145c85d72024b8ca10e6560c62
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>
src/plugins/text/pretty/pretty.c
This page took 0.025768 seconds and 4 git commands to generate.