]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libfdisk: make the library usable with tests
authorKarel Zak <kzak@redhat.com>
Fri, 17 May 2013 10:24:05 +0000 (12:24 +0200)
committerKarel Zak <kzak@redhat.com>
Mon, 16 Sep 2013 14:46:55 +0000 (16:46 +0200)
We don't have completely initialized all label drivers in the tests, so
make the code more robust.

Signed-off-by: Karel Zak <kzak@redhat.com>
libfdisk/src/context.c

index e77274bae19ac2223d697a3921e05c88b92f3235..6ede3e4687f7ee9f4c0d5bd98c1ccb1c417ee802 100644 (file)
@@ -77,7 +77,8 @@ struct fdisk_label *fdisk_context_get_label(struct fdisk_context *cxt, const cha
                return cxt->label;
 
        for (i = 0; i < cxt->nlabels; i++)
-               if (strcmp(cxt->labels[i]->name, name) == 0)
+               if (cxt->labels[i]
+                   && strcmp(cxt->labels[i]->name, name) == 0)
                        return cxt->labels[i];
 
        DBG(LABEL, dbgprint("failed to found %s label driver\n", name));