summaryrefslogtreecommitdiff
path: root/sbin/fsck
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2003-09-25 04:15:30 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2003-09-25 04:15:30 +0000
commit9a2ca4d7379e33069db491536c32a9549abb5e11 (patch)
treeb0ca098c08aba61da938eb63bab139b3601b9434 /sbin/fsck
parent45e0371bc230810e91751f9d108b93561f18f21b (diff)
p = realloc(p is not allowed
Diffstat (limited to 'sbin/fsck')
-rw-r--r--sbin/fsck/fsutil.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/sbin/fsck/fsutil.c b/sbin/fsck/fsutil.c
index 83770177f7a..11253bf2bef 100644
--- a/sbin/fsck/fsutil.c
+++ b/sbin/fsck/fsutil.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: fsutil.c,v 1.12 2003/07/29 18:38:35 deraadt Exp $ */
+/* $OpenBSD: fsutil.c,v 1.13 2003/09/25 04:15:29 deraadt Exp $ */
/* $NetBSD: fsutil.c,v 1.2 1996/10/03 20:06:31 christos Exp $ */
/*
@@ -30,7 +30,7 @@
* SUCH DAMAGE.
*/
#ifndef lint
-static const char rcsid[] = "$OpenBSD: fsutil.c,v 1.12 2003/07/29 18:38:35 deraadt Exp $";
+static const char rcsid[] = "$OpenBSD: fsutil.c,v 1.13 2003/09/25 04:15:29 deraadt Exp $";
#endif /* not lint */
#include <sys/param.h>
@@ -246,12 +246,17 @@ emalloc(size_t s)
void *
erealloc(void *p, size_t s)
{
+ void *newp;
+
if (s == 0)
err(1, "realloc failed");
- p = realloc(p, s);
- if (p == NULL)
+ newp = realloc(p, s);
+ if (newp == NULL) {
+ if (p)
+ free(p);
err(1, "realloc failed");
- return p;
+ }
+ return newp;
}