]> sigrok.org Git - libsigrok.git/commitdiff
analog: avoid double free in '-O analog' shutdown path
authormilan hauth <redacted>
Tue, 28 Jul 2020 15:01:03 +0000 (17:01 +0200)
committerGerhard Sittig <redacted>
Tue, 28 Jul 2020 15:07:22 +0000 (17:07 +0200)
Do void the 'def' and 'values' references for '-O analog' module options
in the shutdown path, to avoid double free calls.

src/output/analog.c

index 5c624e050033729273b0972fb4c6c580cecd80c8..d665b8ec2edaa81182adc50387b0538d6dc70dfe 100644 (file)
@@ -195,8 +195,14 @@ static int cleanup(struct sr_output *o)
        ctx = o->priv;
 
        g_ptr_array_free(ctx->channellist, 1);
-       g_variant_unref(options[0].def);
-       g_slist_free_full(options[0].values, (GDestroyNotify)g_variant_unref);
+       if (options[0].def) {
+               g_variant_unref(options[0].def);
+               options[0].def = NULL;
+       }
+       if (options[0].values) {
+               g_slist_free_full(options[0].values, (GDestroyNotify)g_variant_unref);
+               options[0].values = NULL;
+       }
        g_free(ctx->fdata);
        g_free(ctx);
        o->priv = NULL;