]> sigrok.org Git - libsigrok.git/commitdiff
output/srzip: Prevent memory leak in case filename is empty
authorSoeren Apel <redacted>
Sat, 1 Aug 2015 19:41:32 +0000 (21:41 +0200)
committerUwe Hermann <redacted>
Sat, 15 Aug 2015 21:53:12 +0000 (23:53 +0200)
src/output/srzip.c

index 690736c8f15c1425ed897a2976157a0a1798dcf8..409421cbbf3b862721942d676f66e90dc5149faa 100644 (file)
@@ -41,14 +41,14 @@ static int init(struct sr_output *o, GHashTable *options)
 
        (void)options;
 
-       outc = g_malloc0(sizeof(struct out_context));
-       o->priv = outc;
-
        if (strlen(o->filename) == 0) {
                sr_info("srzip output module requires a file name, cannot save.");
                return SR_ERR_ARG;
        }
+
+       outc = g_malloc0(sizeof(struct out_context));
        outc->filename = g_strdup(o->filename);
+       o->priv = outc;
 
        return SR_OK;
 }