summaryrefslogtreecommitdiffstats
path: root/lib/loopdev.c
diff options
context:
space:
mode:
authorKarel Zak2011-09-12 15:35:33 +0200
committerKarel Zak2011-09-12 15:35:33 +0200
commitfc8b1f36fecce949b14a452bb6e3ba9b67d362c7 (patch)
treece09863b527c4a3345a699f10930f4046e60aa92 /lib/loopdev.c
parentlibmount: variable dereferenced before check [smatch scan] (diff)
downloadkernel-qcow2-util-linux-fc8b1f36fecce949b14a452bb6e3ba9b67d362c7.tar.gz
kernel-qcow2-util-linux-fc8b1f36fecce949b14a452bb6e3ba9b67d362c7.tar.xz
kernel-qcow2-util-linux-fc8b1f36fecce949b14a452bb6e3ba9b67d362c7.zip
libmount: potential null derefence [smatch scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'lib/loopdev.c')
-rw-r--r--lib/loopdev.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/loopdev.c b/lib/loopdev.c
index 81b7d2d6e..de227e226 100644
--- a/lib/loopdev.c
+++ b/lib/loopdev.c
@@ -369,9 +369,10 @@ static int loop_scandir(const char *dirname, int **ary, int hasprefix)
}
*ary = tmp;
}
- (*ary)[count++] = n;
+ if (*ary)
+ (*ary)[count++] = n;
}
- if (count)
+ if (count && *ary)
qsort(*ary, count, sizeof(int), cmpnum);
closedir(dir);