Skip to content
Snippets Groups Projects
Commit a1fc9b80 authored by Daniel Stenberg's avatar Daniel Stenberg Committed by Yang Tse
Browse files

curl_multi_wait: avoid an unnecessary memory allocation

parent dfe382c6
No related branches found
No related tags found
No related merge requests found
......@@ -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;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment