summaryrefslogtreecommitdiff
path: root/usr.sbin/mailwrapper/mailwrapper.c
diff options
context:
space:
mode:
authorJakob Schlyter <jakob@cvs.openbsd.org>1999-08-02 20:25:48 +0000
committerJakob Schlyter <jakob@cvs.openbsd.org>1999-08-02 20:25:48 +0000
commit79f3805fac3ca734a92cc1367cf5c612d101c88d (patch)
tree3d219aeffdd53a2921d92870da8a168191e4c276 /usr.sbin/mailwrapper/mailwrapper.c
parent972d977ef40ab648164da49544fd90fefe7ca7c3 (diff)
Fix realloc bug.
Diffstat (limited to 'usr.sbin/mailwrapper/mailwrapper.c')
-rw-r--r--usr.sbin/mailwrapper/mailwrapper.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/usr.sbin/mailwrapper/mailwrapper.c b/usr.sbin/mailwrapper/mailwrapper.c
index 2b6002d314b..7e90ad435c1 100644
--- a/usr.sbin/mailwrapper/mailwrapper.c
+++ b/usr.sbin/mailwrapper/mailwrapper.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mailwrapper.c,v 1.1 1999/08/02 19:50:08 jakob Exp $ */
+/* $OpenBSD: mailwrapper.c,v 1.2 1999/08/02 20:25:47 jakob Exp $ */
/* $NetBSD: mailwrapper.c,v 1.2 1999/02/20 22:10:07 thorpej Exp $ */
/*
@@ -70,11 +70,20 @@ addarg(al, arg, copy)
const char *arg;
int copy;
{
+ char **argv2;
+
if (al->argc == al->maxc) {
al->maxc <<= 1;
- if ((al->argv = realloc(al->argv,
- al->maxc * sizeof(char *))) == NULL)
- err(1, "mailwrapper");
+
+ if ((argv2 = realloc(al->argv,
+ al->maxc * sizeof(char *))) == NULL) {
+ if (al->argv)
+ free(al->argv);
+ al->argv = NULL;
+ err(1, "mailwrapper");
+ } else {
+ al->argv = argv2;
+ }
}
if (copy) {
if ((al->argv[al->argc++] = strdup(arg)) == NULL)