aboutsummaryrefslogtreecommitdiff
path: root/lib/cookie.c
diff options
context:
space:
mode:
authorMarkus Elfring <elfring@users.sourceforge.net>2015-03-11 17:41:01 +0100
committerDaniel Stenberg <daniel@haxx.se>2015-03-16 12:13:56 +0100
commit29c655c0a6affc0359e499162e8308663eb4d04f (patch)
treeed6b1fc761dee6623ec1b312cc53dc3b661c1550 /lib/cookie.c
parent059b3a5770075315dbc843b9285a1cdec82c12d5 (diff)
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>
Diffstat (limited to 'lib/cookie.c')
-rw-r--r--lib/cookie.c53
1 files changed, 17 insertions, 36 deletions
diff --git a/lib/cookie.c b/lib/cookie.c
index 601ff2a77..b71eab43f 100644
--- a/lib/cookie.c
+++ b/lib/cookie.c
@@ -103,23 +103,14 @@ Example set of cookies:
static void freecookie(struct Cookie *co)
{
- if(co->expirestr)
- free(co->expirestr);
- if(co->domain)
- free(co->domain);
- if(co->path)
- free(co->path);
- if(co->spath)
- free(co->spath);
- if(co->name)
- free(co->name);
- if(co->value)
- free(co->value);
- if(co->maxage)
- free(co->maxage);
- if(co->version)
- free(co->version);
-
+ free(co->expirestr);
+ free(co->domain);
+ free(co->path);
+ free(co->spath);
+ free(co->name);
+ free(co->value);
+ free(co->maxage);
+ free(co->version);
free(co);
}
@@ -296,8 +287,7 @@ void Curl_cookie_loadfiles(struct SessionHandle *data)
*/
static void strstore(char **str, const char *newstr)
{
- if(*str)
- free(*str);
+ free(*str);
*str = strdup(newstr);
}
@@ -832,21 +822,13 @@ Curl_cookie_add(struct SessionHandle *data,
/* then free all the old pointers */
free(clist->name);
- if(clist->value)
- free(clist->value);
- if(clist->domain)
- free(clist->domain);
- if(clist->path)
- free(clist->path);
- if(clist->spath)
- free(clist->spath);
- if(clist->expirestr)
- free(clist->expirestr);
-
- if(clist->version)
- free(clist->version);
- if(clist->maxage)
- free(clist->maxage);
+ free(clist->value);
+ free(clist->domain);
+ free(clist->path);
+ free(clist->spath);
+ free(clist->expirestr);
+ free(clist->version);
+ free(clist->maxage);
*clist = *co; /* then store all the new data */
@@ -1214,8 +1196,7 @@ void Curl_cookie_clearsess(struct CookieInfo *cookies)
void Curl_cookie_cleanup(struct CookieInfo *c)
{
if(c) {
- if(c->filename)
- free(c->filename);
+ free(c->filename);
Curl_cookie_freelist(c->cookies, TRUE);
free(c); /* free the base struct as well */
}