]> sigrok.org Git - libsigrok.git/commitdiff
input/logicport: silence a non-fatal glib runtime assertion
authorGerhard Sittig <redacted>
Sun, 3 Jun 2018 06:37:10 +0000 (08:37 +0200)
committerUwe Hermann <redacted>
Sun, 3 Jun 2018 17:28:46 +0000 (19:28 +0200)
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

src/input/logicport.c

index 273b25d2049a45ce9b4689158be8e1fef01d644c..e165cb04c21459742b60f4f0bd5d6b285460bbe3 100644 (file)
@@ -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;
 }