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 <elfring@users.sourceforge.net>
This commit is contained in:
Markus Elfring
2015-03-11 17:41:01 +01:00
committed by Daniel Stenberg
parent 059b3a5770
commit 29c655c0a6
40 changed files with 152 additions and 339 deletions

View File

@@ -217,8 +217,7 @@ static void sh_freeentry(void *freethis)
{
struct Curl_sh_entry *p = (struct Curl_sh_entry *) freethis;
if(p)
free(p);
free(p);
}
static size_t fd_key_compare(void *k1, size_t k1_len, void *k2, size_t k2_len)
@@ -1582,8 +1581,7 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
if(!retry) {
/* if the URL is a follow-location and not just a retried request
then figure out the URL here */
if(newurl)
free(newurl);
free(newurl);
newurl = data->req.newurl;
data->req.newurl = NULL;
follow = FOLLOW_REDIR;
@@ -1608,8 +1606,7 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
/* but first check to see if we got a location info even though we're
not following redirects */
if(data->req.location) {
if(newurl)
free(newurl);
free(newurl);
newurl = data->req.location;
data->req.location = NULL;
result = Curl_follow(data, newurl, FOLLOW_FAKE);
@@ -1624,8 +1621,7 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
}
}
if(newurl)
free(newurl);
free(newurl);
break;
}