]> git.ipfire.org Git - thirdparty/unbound.git/commitdiff
- Fix #99: Memory leak in ub_ctx (event_base will never be freed).
authorW.C.A. Wijngaards <wouter@nlnetlabs.nl>
Thu, 24 Oct 2019 07:58:45 +0000 (09:58 +0200)
committerW.C.A. Wijngaards <wouter@nlnetlabs.nl>
Thu, 24 Oct 2019 07:58:45 +0000 (09:58 +0200)
doc/Changelog
libunbound/context.h
libunbound/libunbound.c

index 11f59f42f3c65a3615619ffaedd85b7358023bfc..3a00c686e01a354df1cb4ade4e0398f544cae832 100644 (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.
index c3900154f8b439caafa3ecada45c8ff28365c083..78f8731e236ed4e9e301d17d3f364415cdab0ad0 100644 (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;
 
index 63770cc025d960b85b9f85d6b6a394a89d56b9f2..f86f568354daa790cdea8cd49f06e0ebd898b55d 100644 (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();