]> granicus.if.org Git - curl/commitdiff
share_init: fix OOM crash
authorDaniel Stenberg <daniel@haxx.se>
Fri, 22 May 2015 14:26:14 +0000 (16:26 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Fri, 22 May 2015 14:26:14 +0000 (16:26 +0200)
A failed calloc() would lead to NULL pointer use.

Coverity CID 1299427.

lib/share.c

index 7fb068625872175e3dc72bf72c2a4d547be14390..17202486c15796c8b934ff83fae05fa9bdc0b2bf 100644 (file)
@@ -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;