]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libfdisk: fix possible mem leak [coverity scan]
authorKarel Zak <kzak@redhat.com>
Wed, 28 Jan 2015 14:05:14 +0000 (15:05 +0100)
committerKarel Zak <kzak@redhat.com>
Wed, 28 Jan 2015 14:05:14 +0000 (15:05 +0100)
Signed-off-by: Karel Zak <kzak@redhat.com>
libfdisk/src/context.c

index ef8b30b047d0f34a4ef0f1e02678a2e553188167..84867b0abe1e8413fc96df2e7364e9c4e1e48bce 100644 (file)
@@ -149,8 +149,11 @@ struct fdisk_context *fdisk_new_nested_context(struct fdisk_context *parent,
        fdisk_ref_context(parent);
        cxt->parent = parent;
 
-       if (init_nested_from_parent(cxt, 1) != 0)
+       if (init_nested_from_parent(cxt, 1) != 0) {
+               cxt->parent = NULL;
+               fdisk_unref_context(cxt);
                return NULL;
+       }
 
        if (name) {
                if (strcasecmp(name, "bsd") == 0)