]> granicus.if.org Git - curl/commitdiff
curl_multi_wait: OOM handling fix
authorYang Tse <yangsita@gmail.com>
Sun, 23 Dec 2012 20:10:45 +0000 (21:10 +0100)
committerYang Tse <yangsita@gmail.com>
Sun, 23 Dec 2012 20:50:39 +0000 (21:50 +0100)
lib/multi.c

index b3a52d2fe9241fc146bde1a5a002f28a4fb6a7dc..52eeb7f9f28aaaeb0baff4cd9c2e44505554e7a3 100644 (file)
@@ -929,8 +929,11 @@ CURLMcode curl_multi_wait(CURLM *multi_handle,
     easy = easy->next; /* check next handle */
   }
 
-  if(nfds)
-    ufds = (struct pollfd *)malloc(nfds * sizeof(struct pollfd));
+  if(nfds) {
+    ufds = malloc(nfds * sizeof(struct pollfd));
+    if(!ufds)
+      return CURLM_OUT_OF_MEMORY;
+  }
   nfds = 0;
 
   /* Add the curl handles to our pollfds first */