From 76babf87a3062e78fa213f8870a403b3da878020 Mon Sep 17 00:00:00 2001 From: Theo de Raadt Date: Wed, 24 Sep 2003 20:40:20 +0000 Subject: realloc fixes; ok ho --- sbin/disklabel/editor.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'sbin/disklabel/editor.c') 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 @@ -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 @@ -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]); -- cgit v1.2.3