From: Karel Zak Date: Mon, 12 Nov 2012 11:10:52 +0000 (+0100) Subject: lib/loopdev: make loopcxt_get_device() more robust X-Git-Tag: v2.23-rc1~538 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b481b622c566cba8474d8e0206aea42fe6691082;p=thirdparty%2Futil-linux.git lib/loopdev: make loopcxt_get_device() more robust Signed-off-by: Karel Zak --- diff --git a/lib/loopdev.c b/lib/loopdev.c index dc93a69d7e..a404e6644b 100644 --- a/lib/loopdev.c +++ b/lib/loopdev.c @@ -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; } /*