summaryrefslogtreecommitdiffstats
path: root/mount/lomount.c
diff options
context:
space:
mode:
Diffstat (limited to 'mount/lomount.c')
-rw-r--r--mount/lomount.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/mount/lomount.c b/mount/lomount.c
index 54b9f8e9a..03aae4b2a 100644
--- a/mount/lomount.c
+++ b/mount/lomount.c
@@ -258,11 +258,16 @@ loop_scandir(const char *dirname, int **ary, int hasprefix)
if (n == -1 || n < NLOOPS_DEFAULT)
continue;
if (count + 1 > arylen) {
+ int *tmp;
+
arylen += 1;
- *ary = *ary ? realloc(*ary, arylen * sizeof(int)) :
- malloc(arylen * sizeof(int));
- if (!*ary)
+
+ tmp = realloc(*ary, arylen * sizeof(int));
+ if (!tmp) {
+ free(*ary);
return -1;
+ }
+ *ary = tmp;
}
(*ary)[count++] = n;
}