1
0
mirror of https://github.com/moparisthebest/curl synced 2024-11-11 20:15:03 -05:00

sockfilt.c: free memory in case of memory allocation errors

This commit is contained in:
Marc Hoersken 2014-04-20 18:22:28 +02:00
parent ee6791128f
commit eb01947e1d

View File

@ -562,6 +562,7 @@ static int select_ws(int nfds, fd_set *readfds, fd_set *writefds,
/* allocate internal array for the internal event handles */ /* allocate internal array for the internal event handles */
handles = malloc(nfds * sizeof(HANDLE)); handles = malloc(nfds * sizeof(HANDLE));
if(handles == NULL) { if(handles == NULL) {
free(fdarr);
errno = ENOMEM; errno = ENOMEM;
return -1; return -1;
} }
@ -569,6 +570,8 @@ static int select_ws(int nfds, fd_set *readfds, fd_set *writefds,
/* allocate internal array for the internal socket handles */ /* allocate internal array for the internal socket handles */
wsasocks = malloc(nfds * sizeof(curl_socket_t)); wsasocks = malloc(nfds * sizeof(curl_socket_t));
if(wsasocks == NULL) { if(wsasocks == NULL) {
free(handles);
free(fdarr);
errno = ENOMEM; errno = ENOMEM;
return -1; return -1;
} }
@ -576,6 +579,9 @@ static int select_ws(int nfds, fd_set *readfds, fd_set *writefds,
/* allocate internal array for the internal WINSOCK2 events */ /* allocate internal array for the internal WINSOCK2 events */
wsaevents = malloc(nfds * sizeof(WSAEVENT)); wsaevents = malloc(nfds * sizeof(WSAEVENT));
if(wsaevents == NULL) { if(wsaevents == NULL) {
free(wsasocks);
free(handles);
free(fdarr);
errno = ENOMEM; errno = ENOMEM;
return -1; return -1;
} }