Skip to content

Commit

Permalink
Bug #149: Deletion of unnecessary checks before a few calls of cURL f…
Browse files Browse the repository at this point in the history
…unctions

The following functions return immediately if a null pointer was passed.
* Curl_cookie_cleanup
* curl_formfree

It is therefore not needed that a function caller repeats a corresponding check.

This issue was fixed by using the software Coccinelle 1.0.0-rc24.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
  • Loading branch information
elfring authored and bagder committed Mar 16, 2015
1 parent 29c655c commit 9e66160
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 6 deletions.
3 changes: 1 addition & 2 deletions lib/formdata.c
Expand Up @@ -969,8 +969,7 @@ void curl_formfree(struct curl_httppost *form)
next=form->next; /* the following form line */

/* recurse to sub-contents */
if(form->more)
curl_formfree(form->more);
curl_formfree(form->more);

if(!(form->flags & HTTPPOST_PTRNAME))
free(form->name); /* free the name */
Expand Down
3 changes: 1 addition & 2 deletions lib/share.c
Expand Up @@ -198,8 +198,7 @@ curl_share_cleanup(CURLSH *sh)
}

#if !defined(CURL_DISABLE_HTTP) && !defined(CURL_DISABLE_COOKIES)
if(share->cookies)
Curl_cookie_cleanup(share->cookies);
Curl_cookie_cleanup(share->cookies);
#endif

#ifdef USE_SSL
Expand Down
3 changes: 1 addition & 2 deletions lib/url.c
Expand Up @@ -2150,8 +2150,7 @@ CURLcode Curl_setopt(struct SessionHandle *data, CURLoption option,
#if !defined(CURL_DISABLE_HTTP) && !defined(CURL_DISABLE_COOKIES)
if(data->share->cookies) {
/* use shared cookie list, first free own one if any */
if(data->cookies)
Curl_cookie_cleanup(data->cookies);
Curl_cookie_cleanup(data->cookies);
/* enable cookies since we now use a share that uses cookies! */
data->cookies = data->share->cookies;
}
Expand Down

0 comments on commit 9e66160

Please sign in to comment.