summaryrefslogtreecommitdiffstats
path: root/lib/loopdev.c
diff options
context:
space:
mode:
authorKarel Zak2012-11-12 12:10:52 +0100
committerKarel Zak2012-11-12 12:10:52 +0100
commitb481b622c566cba8474d8e0206aea42fe6691082 (patch)
tree301aff50cba7a91309b6d3ab7718b85fb9baf552 /lib/loopdev.c
parentlib/console: fix possible fd leak (diff)
downloadkernel-qcow2-util-linux-b481b622c566cba8474d8e0206aea42fe6691082.tar.gz
kernel-qcow2-util-linux-b481b622c566cba8474d8e0206aea42fe6691082.tar.xz
kernel-qcow2-util-linux-b481b622c566cba8474d8e0206aea42fe6691082.zip
lib/loopdev: make loopcxt_get_device() more robust
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'lib/loopdev.c')
-rw-r--r--lib/loopdev.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/loopdev.c b/lib/loopdev.c
index dc93a69d7..a404e6644 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;
}
/*