From: Simon Marchi Date: Tue, 15 Oct 2019 18:32:00 +0000 (-0400) Subject: Fix: destroy_pretty_data: move NULL check earlier X-Git-Url: http://git.efficios.com/?p=babeltrace.git;a=commitdiff_plain;h=96eccbbcd37201bf462fe0d655ca77ecb81b7e1e Fix: destroy_pretty_data: move NULL check earlier Move the NULL check for pretty before we dereference it. Reported-by: Coverity Change-Id: I2e598e734d4503ec17754dabf915d8264edcf4a7 Signed-off-by: Simon Marchi Reviewed-on: https://review.lttng.org/c/babeltrace/+/2179 Reviewed-by: Francis Deslauriers Tested-by: jenkins --- diff --git a/src/plugins/text/pretty/pretty.c b/src/plugins/text/pretty/pretty.c index a925b7d8..3ea6c54a 100644 --- a/src/plugins/text/pretty/pretty.c +++ b/src/plugins/text/pretty/pretty.c @@ -46,12 +46,12 @@ const char * const in_port_name = "in"; static void destroy_pretty_data(struct pretty_component *pretty) { - bt_self_component_port_input_message_iterator_put_ref(pretty->iterator); - if (!pretty) { goto end; } + bt_self_component_port_input_message_iterator_put_ref(pretty->iterator); + if (pretty->string) { (void) g_string_free(pretty->string, TRUE); }