Skip to content

Commit

Permalink
share_init: fix OOM crash
Browse files Browse the repository at this point in the history
A failed calloc() would lead to NULL pointer use.

Coverity CID 1299427.
  • Loading branch information
bagder committed May 22, 2015
1 parent 817323e commit 03e2a9b
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions lib/share.c
Expand Up @@ -35,12 +35,13 @@ CURLSH *
curl_share_init(void)
{
struct Curl_share *share = calloc(1, sizeof(struct Curl_share));
if(share)
if(share) {
share->specifier |= (1<<CURL_LOCK_DATA_SHARE);

if(Curl_mk_dnscache(&share->hostcache)) {
free(share);
return NULL;
if(Curl_mk_dnscache(&share->hostcache)) {
free(share);
return NULL;
}
}

return share;
Expand Down

0 comments on commit 03e2a9b

Please sign in to comment.