Skip to content

Commit

Permalink
event_base_once: fix potential null pointer threat
Browse files Browse the repository at this point in the history
supposing if base is null, EVBASE_ACQUIRE_LOCK and EVBASE_RELEASE_LOCK
would get a coredump, so we add a guard for protection.

Signed-off-by: chenguolong <[email protected]>
  • Loading branch information
chenguolong authored and azat committed Feb 15, 2020
1 parent 5fbe631 commit 968bbd5
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions event.c
Original file line number Diff line number Diff line change
Expand Up @@ -2091,6 +2091,9 @@ event_base_once(struct event_base *base, evutil_socket_t fd, short events,
int res = 0;
int activate = 0;

if (!base)
return (-1);

/* We cannot support signals that just fire once, or persistent
* events. */
if (events & (EV_SIGNAL|EV_PERSIST))
Expand Down

0 comments on commit 968bbd5

Please sign in to comment.