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
This commit is contained in:
Gerhard Sittig 2018-06-03 08:37:10 +02:00 committed by Uwe Hermann
parent a38c2bfbbb
commit 49d9a095e8
1 changed files with 4 additions and 2 deletions

View File

@ -1133,6 +1133,7 @@ static void cleanup(struct sr_input *in)
* and scalars, so that re-runs start out fresh again. * and scalars, so that re-runs start out fresh again.
*/ */
g_free(inc->sw_version); g_free(inc->sw_version);
if (inc->cont_buff)
g_string_free(inc->cont_buff, TRUE); g_string_free(inc->cont_buff, TRUE);
g_free(inc->sample_data_queue); g_free(inc->sample_data_queue);
for (idx = 0; idx < inc->channel_count; idx++) for (idx = 0; idx < inc->channel_count; idx++)
@ -1154,6 +1155,7 @@ static int reset(struct sr_input *in)
inc->ch_feed_prep = FALSE; inc->ch_feed_prep = FALSE;
inc->header_sent = FALSE; inc->header_sent = FALSE;
inc->rate_sent = FALSE; inc->rate_sent = FALSE;
if (in->buf)
g_string_truncate(in->buf, 0); g_string_truncate(in->buf, 0);
return SR_OK; return SR_OK;