Commit 03e2a9b0 authored by Daniel Stenberg's avatar Daniel Stenberg
Browse files

share_init: fix OOM crash

A failed calloc() would lead to NULL pointer use.

Coverity CID 1299427.
parent 817323ed
Loading
Loading
Loading
Loading
+5 −4
Original line number Diff line number Diff line
@@ -35,13 +35,14 @@ 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;
    }
  }

  return share;
}