mirror of
https://gitlab.freedesktop.org/dbus/dbus.git
synced 2026-06-07 15:18:18 +02:00
Fix bug not detecting out of memory condition in _dbus_poll_events ()
For cleaning purpose the event list members are initialized with WSA_INVALID_EVENT. The cleanup code detects and handles the case that the event list has been created from calloc ().
This commit is contained in:
parent
0d714aed9d
commit
96b8295831
1 changed files with 19 additions and 5 deletions
|
|
@ -1186,6 +1186,16 @@ _dbus_poll_events (DBusPollFD *fds,
|
|||
else
|
||||
pEvents = eventsOnStack;
|
||||
|
||||
if (pEvents == NULL)
|
||||
{
|
||||
_dbus_win_set_errno (ENOMEM);
|
||||
ret = -1;
|
||||
goto oom;
|
||||
}
|
||||
|
||||
for (i = 0; i < n_fds; i++)
|
||||
pEvents[i] = WSA_INVALID_EVENT;
|
||||
|
||||
for (i = 0; i < n_fds; i++)
|
||||
{
|
||||
DBusPollFD *fdp = &fds[i];
|
||||
|
|
@ -1251,14 +1261,18 @@ _dbus_poll_events (DBusPollFD *fds,
|
|||
ret = -1;
|
||||
}
|
||||
|
||||
for(i = 0; i < n_fds; i++)
|
||||
oom:
|
||||
if (pEvents != NULL)
|
||||
{
|
||||
WSACloseEvent (pEvents[i]);
|
||||
for (i = 0; i < n_fds; i++)
|
||||
{
|
||||
if (pEvents[i] != WSA_INVALID_EVENT)
|
||||
WSACloseEvent (pEvents[i]);
|
||||
}
|
||||
if (n_fds > DBUS_STACK_WSAEVENTS)
|
||||
free (pEvents);
|
||||
}
|
||||
|
||||
if (n_fds > DBUS_STACK_WSAEVENTS)
|
||||
free (pEvents);
|
||||
|
||||
return ret;
|
||||
}
|
||||
#else
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue