From 5d1cc1f2e49619d168b935c6595ad7107ec10136 Mon Sep 17 00:00:00 2001 From: Reyk Floeter Date: Thu, 3 Dec 2015 11:46:26 +0000 Subject: Remove unnecessary NULL checks before free(). From Jan Schreiber --- usr.sbin/httpd/httpd.c | 6 +++--- usr.sbin/httpd/server_http.c | 34 +++++++++++++--------------------- 2 files changed, 16 insertions(+), 24 deletions(-) (limited to 'usr.sbin') diff --git a/usr.sbin/httpd/httpd.c b/usr.sbin/httpd/httpd.c index 22575c51ad7..0dc9409f6d7 100644 --- a/usr.sbin/httpd/httpd.c +++ b/usr.sbin/httpd/httpd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: httpd.c,v 1.52 2015/12/03 07:01:29 deraadt Exp $ */ +/* $OpenBSD: httpd.c,v 1.53 2015/12/03 11:46:25 reyk Exp $ */ /* * Copyright (c) 2014 Reyk Floeter @@ -1197,8 +1197,8 @@ void media_delete(struct mediatypes *types, struct media_type *media) { RB_REMOVE(mediatypes, types, media); - if (media->media_encoding != NULL) - free(media->media_encoding); + + free(media->media_encoding); free(media); } diff --git a/usr.sbin/httpd/server_http.c b/usr.sbin/httpd/server_http.c index d8cf256be9e..fdf39f3cd63 100644 --- a/usr.sbin/httpd/server_http.c +++ b/usr.sbin/httpd/server_http.c @@ -1,4 +1,4 @@ -/* $OpenBSD: server_http.c,v 1.101 2015/10/13 08:33:06 sunil Exp $ */ +/* $OpenBSD: server_http.c,v 1.102 2015/12/03 11:46:25 reyk Exp $ */ /* * Copyright (c) 2006 - 2015 Reyk Floeter @@ -102,26 +102,18 @@ server_httpdesc_free(struct http_descriptor *desc) { if (desc == NULL) return; - if (desc->http_path != NULL) { - free(desc->http_path); - desc->http_path = NULL; - } - if (desc->http_path_alias != NULL) { - free(desc->http_path_alias); - desc->http_path_alias = NULL; - } - if (desc->http_query != NULL) { - free(desc->http_query); - desc->http_query = NULL; - } - if (desc->http_version != NULL) { - free(desc->http_version); - desc->http_version = NULL; - } - if (desc->http_host != NULL) { - free(desc->http_host); - desc->http_host = NULL; - } + + free(desc->http_path); + desc->http_path = NULL; + free(desc->http_path_alias); + desc->http_path_alias = NULL; + free(desc->http_query); + desc->http_query = NULL; + free(desc->http_version); + desc->http_version = NULL; + free(desc->http_host); + desc->http_host = NULL; + kv_purge(&desc->http_headers); desc->http_lastheader = NULL; desc->http_method = 0; -- cgit v1.2.3