]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
lib/loopdev: make loopcxt_get_device() more robust
authorKarel Zak <kzak@redhat.com>
Mon, 12 Nov 2012 11:10:52 +0000 (12:10 +0100)
committerKarel Zak <kzak@redhat.com>
Fri, 16 Nov 2012 10:27:50 +0000 (11:27 +0100)
Signed-off-by: Karel Zak <kzak@redhat.com>
lib/loopdev.c

index f62af83c289ac33e5600a37bc6ee88403ddff62c..13fd74780a9e141a90015760ece1b7792928ee59 100644 (file)
@@ -232,7 +232,7 @@ void loopcxt_enable_debug(struct loopdev_cxt *lc, int enable)
  */
 char *loopcxt_strdup_device(struct loopdev_cxt *lc)
 {
-       if (!lc || !*lc->device)
+       if (!lc || !lc->device || !*lc->device)
                return NULL;
        return strdup(lc->device);
 }
@@ -244,7 +244,7 @@ char *loopcxt_strdup_device(struct loopdev_cxt *lc)
  */
 const char *loopcxt_get_device(struct loopdev_cxt *lc)
 {
-       return lc ? lc->device : NULL;
+       return lc && lc->device && *lc->device ? lc->device : NULL;
 }
 
 /*