summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKenneth R Westerback <krw@cvs.openbsd.org>2015-02-01 18:43:40 +0000
committerKenneth R Westerback <krw@cvs.openbsd.org>2015-02-01 18:43:40 +0000
commit3819587c7729c16a8490735e96f1fcc8736e71bb (patch)
tree236dbf54b8c66c553da3d10f086b59122c5e22d1
parent33f94a44cb0d76a11701410527e4b8cc05bec6e5 (diff)
free(NULL) works, so stop checking for non-zero length allocation
or non-NULLness before calling free(). This batch from Benjamin Baier.
-rw-r--r--sbin/dhclient/clparse.c8
-rw-r--r--sbin/dhclient/dhclient.c18
2 files changed, 10 insertions, 16 deletions
diff --git a/sbin/dhclient/clparse.c b/sbin/dhclient/clparse.c
index 2451bca3bec..f0bd69ac23e 100644
--- a/sbin/dhclient/clparse.c
+++ b/sbin/dhclient/clparse.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: clparse.c,v 1.90 2014/11/03 22:06:39 krw Exp $ */
+/* $OpenBSD: clparse.c,v 1.91 2015/02/01 18:43:39 krw Exp $ */
/* Parser for dhclient config and lease files. */
@@ -254,14 +254,12 @@ parse_client_statement(FILE *cfile)
break;
case TOK_FILENAME:
string = parse_string(cfile);
- if (config->filename)
- free(config->filename);
+ free(config->filename);
config->filename = string;
break;
case TOK_SERVER_NAME:
string = parse_string(cfile);
- if (config->server_name)
- free(config->server_name);
+ free(config->server_name);
config->server_name = string;
break;
case TOK_FIXED_ADDR:
diff --git a/sbin/dhclient/dhclient.c b/sbin/dhclient/dhclient.c
index f91db91de4e..3d13742ffe2 100644
--- a/sbin/dhclient/dhclient.c
+++ b/sbin/dhclient/dhclient.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dhclient.c,v 1.351 2015/01/31 23:18:29 krw Exp $ */
+/* $OpenBSD: dhclient.c,v 1.352 2015/02/01 18:43:39 krw Exp $ */
/*
* Copyright 2004 Henning Brauer <henning@openbsd.org>
@@ -877,13 +877,11 @@ bind_lease(void)
int seen;
/*
- * If it's been here before (e.g. static lease), clear out any
- * old resolv_conf.
+ * Clear out any old resolv_conf in case the lease has been here
+ * before (e.g. static lease).
*/
- if (client->new->resolv_conf) {
- free(client->new->resolv_conf);
- client->new->resolv_conf = NULL;
- }
+ free(client->new->resolv_conf);
+ client->new->resolv_conf = NULL;
lease = apply_defaults(client->new);
options = lease->options;
@@ -2144,13 +2142,11 @@ apply_defaults(struct client_lease *lease)
error("Unable to clone lease");
if (config->filename) {
- if (newlease->filename)
- free(newlease->filename);
+ free(newlease->filename);
newlease->filename = strdup(config->filename);
}
if (config->server_name) {
- if (newlease->server_name)
- free(newlease->server_name);
+ free(newlease->server_name);
newlease->server_name = strdup(config->server_name);
}
if (config->address.s_addr != INADDR_ANY)