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)
committerFrancis Deslauriers <francis.deslauriers@efficios.com>
Tue, 15 Oct 2019 14:31:28 +0000 (10:31 -0400)
commit27a1afa74b56f211aa0a44acf268501b73c15aa9
treed3ca3a1a2f1d1930a2d7728a2054f79f2d40ae76
parent0f1979c3efe2c5b253edb5944d2ba561347ece2e
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.030473 seconds and 4 git commands to generate.