- Fix #99: Memory leak in ub_ctx (event_base will never be freed).

This commit is contained in:
W.C.A. Wijngaards 2019-10-24 09:58:45 +02:00
parent 941b324187
commit 7dfbcdf276
3 changed files with 9 additions and 0 deletions

View file

@ -1,3 +1,6 @@
24 October 2019: Wouter
- Fix #99: Memory leak in ub_ctx (event_base will never be freed).
23 October 2019: George
- Add new configure option `--enable-fully-static` to enable full static
build if requested; in relation to #91.

View file

@ -119,6 +119,9 @@ struct ub_ctx {
/** event base for event oriented interface */
struct ub_event_base* event_base;
/** true if the event_base is a pluggable base that is malloced
* with a user event base inside, if so, clean up the pluggable alloc*/
int event_base_malloced;
/** libworker for event based interface */
struct libworker* event_worker;

View file

@ -226,6 +226,7 @@ ub_ctx_create_event(struct event_base* eb)
ub_ctx_delete(ctx);
return NULL;
}
ctx->event_base_malloced = 1;
return ctx;
}
@ -336,6 +337,8 @@ ub_ctx_delete(struct ub_ctx* ctx)
log_file(NULL);
ctx_logfile_overridden = 0;
}
if(ctx->event_base_malloced)
free(ctx->event_base);
free(ctx);
#ifdef USE_WINSOCK
WSACleanup();