From 29c655c0a6affc0359e499162e8308663eb4d04f Mon Sep 17 00:00:00 2001 From: Markus Elfring Date: Wed, 11 Mar 2015 17:41:01 +0100 Subject: Bug #149: Deletion of unnecessary checks before calls of the function "free" The function "free" is documented in the way that no action shall occur for a passed null pointer. It is therefore not needed that a function caller repeats a corresponding check. http://stackoverflow.com/questions/18775608/free-a-null-pointer-anyway-or-check-first This issue was fixed by using the software Coccinelle 1.0.0-rc24. Signed-off-by: Markus Elfring --- lib/vtls/nss.c | 6 ++---- lib/vtls/vtls.c | 3 +-- 2 files changed, 3 insertions(+), 6 deletions(-) (limited to 'lib/vtls') diff --git a/lib/vtls/nss.c b/lib/vtls/nss.c index d1309dd04..82fab8597 100644 --- a/lib/vtls/nss.c +++ b/lib/vtls/nss.c @@ -1245,10 +1245,8 @@ void Curl_nss_close(struct connectdata *conn, int sockindex) * authentication data from a previous connection. */ SSL_InvalidateSession(connssl->handle); - if(connssl->client_nickname != NULL) { - free(connssl->client_nickname); - connssl->client_nickname = NULL; - } + free(connssl->client_nickname); + connssl->client_nickname = NULL; /* destroy all NSS objects in order to avoid failure of NSS shutdown */ Curl_llist_destroy(connssl->obj_list, NULL); connssl->obj_list = NULL; diff --git a/lib/vtls/vtls.c b/lib/vtls/vtls.c index c411b9a73..2230a0433 100644 --- a/lib/vtls/vtls.c +++ b/lib/vtls/vtls.c @@ -463,9 +463,8 @@ CURLcode Curl_ssl_addsessionid(struct connectdata *conn, store->sessionid = ssl_sessionid; store->idsize = idsize; store->age = *general_age; /* set current age */ - if(store->name) /* free it if there's one already present */ - free(store->name); + free(store->name); store->name = clone_host; /* clone host name */ store->remote_port = conn->remote_port; /* port number */ -- cgit v1.2.3