From: Nick Mathewson Date: Thu, 13 Jan 2011 01:28:47 +0000 (-0500) Subject: Correctly free selectop fields when select_resize fails in select_init X-Git-Tag: release-2.0.11-stable~76 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=0c0ec0be2ba977b8133294e27b076a65a2d65711;p=libevent Correctly free selectop fields when select_resize fails in select_init --- diff --git a/select.c b/select.c index 8327518e..94956318 100644 --- a/select.c +++ b/select.c @@ -90,6 +90,7 @@ const struct eventop selectops = { }; static int select_resize(struct selectop *sop, int fdsz); +static void select_free_selectop(struct selectop *sop); static void * select_init(struct event_base *base) @@ -100,9 +101,7 @@ select_init(struct event_base *base) return (NULL); if (select_resize(sop, howmany(32 + 1, NFDBITS)*sizeof(fd_mask))) { - /* select_resize might have left this around. */ - if (sop->event_readset_in) - mm_free(sop->event_readset_in); + select_free_selectop(sop); return (NULL); } @@ -306,11 +305,8 @@ select_del(struct event_base *base, int fd, short old, short events, void *p) } static void -select_dealloc(struct event_base *base) +select_free_selectop(struct selectop *sop) { - struct selectop *sop = base->evbase; - - evsig_dealloc(base); if (sop->event_readset_in) mm_free(sop->event_readset_in); if (sop->event_writeset_in) @@ -323,3 +319,11 @@ select_dealloc(struct event_base *base) memset(sop, 0, sizeof(struct selectop)); mm_free(sop); } + +static void +select_dealloc(struct event_base *base) +{ + evsig_dealloc(base); + + select_free_selectop(base->evbase); +}