From a1fc9b80c842e74243b6a0e52f2c64e4a96210ce Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Sun, 23 Dec 2012 21:06:40 +0100 Subject: curl_multi_wait: avoid an unnecessary memory allocation --- lib/multi.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/multi.c b/lib/multi.c index 2905a1346..b3a52d2fe 100644 --- a/lib/multi.c +++ b/lib/multi.c @@ -900,7 +900,7 @@ CURLMcode curl_multi_wait(CURLM *multi_handle, int bitmap; unsigned int i; unsigned int nfds = extra_nfds; - struct pollfd *ufds; + struct pollfd *ufds = NULL; if(!GOOD_MULTI_HANDLE(multi)) return CURLM_BAD_HANDLE; @@ -929,7 +929,8 @@ CURLMcode curl_multi_wait(CURLM *multi_handle, easy = easy->next; /* check next handle */ } - ufds = (struct pollfd *)malloc(nfds * sizeof(struct pollfd)); + if(nfds) + ufds = (struct pollfd *)malloc(nfds * sizeof(struct pollfd)); nfds = 0; /* Add the curl handles to our pollfds first */ @@ -979,7 +980,7 @@ CURLMcode curl_multi_wait(CURLM *multi_handle, else i = 0; - free(ufds); + Curl_safefree(ufds); if(ret) *ret = i; return CURLM_OK; -- cgit v1.2.3