diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2003-09-25 04:15:30 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2003-09-25 04:15:30 +0000 |
commit | 9a2ca4d7379e33069db491536c32a9549abb5e11 (patch) | |
tree | b0ca098c08aba61da938eb63bab139b3601b9434 /sbin | |
parent | 45e0371bc230810e91751f9d108b93561f18f21b (diff) |
p = realloc(p is not allowed
Diffstat (limited to 'sbin')
-rw-r--r-- | sbin/fsck/fsutil.c | 15 |
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; } |