]> sigrok.org Git - libsigrok.git/blobdiff - src/output/wav.c
output: fix options memory leak
[libsigrok.git] / src / output / wav.c
index 507e0e77b53700ad2e9ac71cac01b3730a008e34..14ef36df185c3b862529be98767dedb214943cd5 100644 (file)
@@ -338,6 +338,19 @@ static int receive(const struct sr_output *o, const struct sr_datafeed_packet *p
        return SR_OK;
 }
 
+static struct sr_option options[] = {
+       { "scale", "Scale", "Scale values by factor", NULL, NULL },
+       ALL_ZERO
+};
+
+static const struct sr_option *get_options(void)
+{
+       if (!options[0].def)
+               options[0].def = g_variant_ref_sink(g_variant_new_double(0.0));
+
+       return options;
+}
+
 static int cleanup(struct sr_output *o)
 {
        struct out_context *outc;
@@ -345,6 +358,7 @@ static int cleanup(struct sr_output *o)
 
        outc = o->priv;
        g_slist_free(outc->channels);
+       g_variant_unref(options[0].def);
        for (i = 0; i < outc->num_channels; i++)
                g_free(outc->chanbuf[i]);
        g_free(outc->chanbuf_used);
@@ -355,19 +369,6 @@ static int cleanup(struct sr_output *o)
        return SR_OK;
 }
 
-static struct sr_option options[] = {
-       { "scale", "Scale", "Scale values by factor", NULL, NULL },
-       ALL_ZERO
-};
-
-static const struct sr_option *get_options(void)
-{
-       if (!options[0].def)
-               options[0].def = g_variant_ref_sink(g_variant_new_double(0.0));
-
-       return options;
-}
-
 SR_PRIV struct sr_output_module output_wav = {
        .id = "wav",
        .name = "WAV",