From: Gerhard Sittig Date: Sun, 3 Jun 2018 06:37:10 +0000 (+0200) Subject: input/logicport: silence a non-fatal glib runtime assertion X-Git-Url: https://sigrok.org/gitweb/?p=libsigrok.git;a=commitdiff_plain;h=49d9a095e8611674466d10f4e8cba9078ae2d2c0;ds=sidebyside input/logicport: silence a non-fatal glib runtime assertion Explicitly check GString pointers for validity before calling glib routines that would access string content. This silences an assertion error for a non-fatal runtime condition: (process:17044): GLib-CRITICAL **: g_string_free: assertion 'string != NULL' failed --- diff --git a/src/input/logicport.c b/src/input/logicport.c index 273b25d2..e165cb04 100644 --- a/src/input/logicport.c +++ b/src/input/logicport.c @@ -1133,7 +1133,8 @@ static void cleanup(struct sr_input *in) * and scalars, so that re-runs start out fresh again. */ g_free(inc->sw_version); - g_string_free(inc->cont_buff, TRUE); + if (inc->cont_buff) + g_string_free(inc->cont_buff, TRUE); g_free(inc->sample_data_queue); for (idx = 0; idx < inc->channel_count; idx++) g_free(inc->wire_names[idx]); @@ -1154,7 +1155,8 @@ static int reset(struct sr_input *in) inc->ch_feed_prep = FALSE; inc->header_sent = FALSE; inc->rate_sent = FALSE; - g_string_truncate(in->buf, 0); + if (in->buf) + g_string_truncate(in->buf, 0); return SR_OK; }