From: Karel Zak Date: Fri, 17 May 2013 10:24:05 +0000 (+0200) Subject: libfdisk: make the library usable with tests X-Git-Tag: v2.24-rc1~248 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=7ab242ecbe715922f82442a261aa7cbc6d6e132e;p=thirdparty%2Futil-linux.git libfdisk: make the library usable with tests We don't have completely initialized all label drivers in the tests, so make the code more robust. Signed-off-by: Karel Zak --- diff --git a/libfdisk/src/context.c b/libfdisk/src/context.c index e77274bae1..6ede3e4687 100644 --- a/libfdisk/src/context.c +++ b/libfdisk/src/context.c @@ -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));