select: avoid a NULL deref in cwfds_add_sock
curl_multi_waitfds(m, NULL, ...); => Curl_waitfds_init(&cwfds, ufds, size); => Curl_waitfds_add_ps(&cwfds); => cwfds_add_sock(cwfds, ...); Would then try to use the ->wfds array while set to NULL previously. This should not happen, which this is now also protected with an assert to trigger debug builds if it happens. Caught by CodeSonar Assisted-by: Jay Satiro Closes #15881
This commit is contained in:
parent
26a672260b
commit
af4e85925d
@ -503,7 +503,10 @@ static unsigned int cwfds_add_sock(struct curl_waitfds *cwfds,
|
||||
curl_socket_t sock, short events)
|
||||
{
|
||||
int i;
|
||||
|
||||
if(!cwfds->wfds) {
|
||||
DEBUGASSERT(!cwfds->count && !cwfds->n);
|
||||
return 1;
|
||||
}
|
||||
if(cwfds->n <= INT_MAX) {
|
||||
for(i = (int)cwfds->n - 1; i >= 0; --i) {
|
||||
if(sock == cwfds->wfds[i].fd) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user