fixed some memory leaks in mio_sys_finimux() when EPOLL is enabled.

fixed a double memory free issue in mio_dev_make()
This commit is contained in:
hyung-hwan 2020-05-24 02:27:54 +00:00
parent bf595d51f1
commit bc9d849b8a
2 changed files with 22 additions and 1 deletions

View File

@ -850,6 +850,7 @@ oops_after_make:
return MIO_NULL;
}
return MIO_NULL;
oops:
mio_freemem (mio, dev);

View File

@ -54,8 +54,28 @@ int mio_sys_initmux (mio_t* mio)
void mio_sys_finimux (mio_t* mio)
{
mio_sys_mux_t* mux = &mio->sysdep->mux;
#if defined(USE_EPOLL)
#if defined(USE_POLL)
if (mux->map.ptr)
{
mio_freemem (mio, mux->map.ptr);
mux->map.ptr = MIO_NULL;
mux->map.capa = 0;
}
if (mux->pd.pfd)
{
mio_freemem (mio, mux->pd.pfd);
mux->pd.pfd = MIO_NULL;
}
if (mux->pd.dptr)
{
mio_freemem (mio, mux->pd.dptr);
mux->pd.dptr = MIO_NULL;
}
mux->pd.capa = 0;
#elif defined(USE_EPOLL)
close (mux->hnd);
mux->hnd = MIO_SYSHND_INVALID;
#endif
}