diff options
author | Peter Valchev <pvalchev@cvs.openbsd.org> | 2003-09-26 06:01:43 +0000 |
---|---|---|
committer | Peter Valchev <pvalchev@cvs.openbsd.org> | 2003-09-26 06:01:43 +0000 |
commit | 35ad2f35226d93d8529515f531dee25d01a17280 (patch) | |
tree | 559da7af7e7804fcfa094ff55044cdd4fcc196a3 /usr.sbin/dhcp/dhclient | |
parent | b271c2cc29581f93e70d10ce2b71d94b6fb660c8 (diff) |
realloc fixes; ok deraadt millert
Diffstat (limited to 'usr.sbin/dhcp/dhclient')
-rw-r--r-- | usr.sbin/dhcp/dhclient/dhclient.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/usr.sbin/dhcp/dhclient/dhclient.c b/usr.sbin/dhcp/dhclient/dhclient.c index 67c74af97a6..ae3786cc175 100644 --- a/usr.sbin/dhcp/dhclient/dhclient.c +++ b/usr.sbin/dhcp/dhclient/dhclient.c @@ -2149,11 +2149,18 @@ void script_set_env (client, prefix, name, value) } else { /* New variable. Expand if necessary. */ if (i >= client->scriptEnvsize - 1) { - client->scriptEnvsize += 50; - client->scriptEnv = realloc(client->scriptEnv, - client->scriptEnvsize); - if (client->scriptEnv == NULL) + char **newscriptEnv; + int newscriptEnvsize = client->scriptEnvsize + 50; + newscriptEnv = realloc(client->scriptEnv, + newscriptEnvsize); + if (newscriptEnv == NULL) { + free(client->scriptEnv); + client->scriptEnv = NULL; + client->scriptEnvsize = 0; error("script_set_env: no memory for variable"); + } + client->scriptEnv = newscriptEnv; + client->scriptEnvsize = newscriptEnvsize; } /* need to set the NULL pointer at end of array beyond the new slot. */ |