diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2003-09-24 20:40:20 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2003-09-24 20:40:20 +0000 |
commit | 76babf87a3062e78fa213f8870a403b3da878020 (patch) | |
tree | 5a9e5e5c1c3cf4e28d259f8aa172987941098131 /sbin | |
parent | 3ee08ce607314cf704bf3875b67bc414b72a0464 (diff) |
realloc fixes; ok ho
Diffstat (limited to 'sbin')
-rw-r--r-- | sbin/disklabel/editor.c | 10 | ||||
-rw-r--r-- | sbin/fsirand/fsirand.c | 9 |
2 files changed, 12 insertions, 7 deletions
diff --git a/sbin/disklabel/editor.c b/sbin/disklabel/editor.c index 9503a821a4c..2e2ed1e975b 100644 --- a/sbin/disklabel/editor.c +++ b/sbin/disklabel/editor.c @@ -1,4 +1,4 @@ -/* $OpenBSD: editor.c,v 1.90 2003/08/29 00:17:09 tedu Exp $ */ +/* $OpenBSD: editor.c,v 1.91 2003/09/24 20:40:19 deraadt Exp $ */ /* * Copyright (c) 1997-2000 Todd C. Miller <Todd.Miller@courtesan.com> @@ -17,7 +17,7 @@ */ #ifndef lint -static char rcsid[] = "$OpenBSD: editor.c,v 1.90 2003/08/29 00:17:09 tedu Exp $"; +static char rcsid[] = "$OpenBSD: editor.c,v 1.91 2003/09/24 20:40:19 deraadt Exp $"; #endif /* not lint */ #include <sys/types.h> @@ -1887,14 +1887,16 @@ char ** mpcopy(char **to, char **from) { int i; + char *top; for (i = 0; i < MAXPARTITIONS; i++) { if (from[i] != NULL) { int len = strlen(from[i]) + 1; - to[i] = realloc(to[i], len); - if (to[i] == NULL) + top = realloc(to[i], len); + if (top == NULL) errx(4, "out of memory"); + to[i] = top; (void)strlcpy(to[i], from[i], len); } else if (to[i] != NULL) { free(to[i]); diff --git a/sbin/fsirand/fsirand.c b/sbin/fsirand/fsirand.c index 5fd052d6b79..41f7ea67e0f 100644 --- a/sbin/fsirand/fsirand.c +++ b/sbin/fsirand/fsirand.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fsirand.c,v 1.19 2003/08/25 23:28:15 tedu Exp $ */ +/* $OpenBSD: fsirand.c,v 1.20 2003/09/24 20:40:19 deraadt Exp $ */ /* * Copyright (c) 1997 Todd C. Miller <Todd.Miller@courtesan.com> @@ -17,7 +17,7 @@ */ #ifndef lint -static char rcsid[] = "$OpenBSD: fsirand.c,v 1.19 2003/08/25 23:28:15 tedu Exp $"; +static char rcsid[] = "$OpenBSD: fsirand.c,v 1.20 2003/09/24 20:40:19 deraadt Exp $"; #endif /* not lint */ #include <sys/types.h> @@ -179,8 +179,11 @@ fsirand(char *device) /* XXX - should really cap buffer at 512kb or so */ ibufsize = sizeof(struct ufs1_dinode) * sblock->fs_ipg; if (oldibufsize < ibufsize) { - if ((inodebuf = realloc(inodebuf, ibufsize)) == NULL) + struct ufs1_dinode *ib; + + if ((ib = realloc(inodebuf, ibufsize)) == NULL) errx(1, "Can't allocate memory for inode buffer"); + inodebuf = ib; oldibufsize = ibufsize; } |