]> 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>
Mon, 12 Nov 2012 11:10:52 +0000 (12:10 +0100)
Signed-off-by: Karel Zak <kzak@redhat.com>
lib/loopdev.c

index dc93a69d7e5e64db7bc4b232702f9a5c1046a6e1..a404e6644be625429d688673e9d85dacac6179ba 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;
 }
 
 /*