]> git.ipfire.org Git - thirdparty/unbound.git/commitdiff
prevent memory leak in case cache isn't reused 569/head
authorJINMEI Tatuya <jtatuya@infoblox.com>
Fri, 22 Jul 2022 21:33:21 +0000 (14:33 -0700)
committerJINMEI Tatuya <jtatuya@infoblox.com>
Fri, 22 Jul 2022 21:33:21 +0000 (14:33 -0700)
daemon/daemon.c

index e70ece168cc975f574e48fb4f794f12348348b3d..2b4c380285335527d6fed3a39e036b9fa69bf956 100644 (file)
@@ -788,13 +788,13 @@ daemon_cleanup(struct daemon* daemon)
                worker_delete(daemon->workers[i]);
        free(daemon->workers);
        daemon->workers = NULL;
-       daemon->num = 0;
        /* Unless we're trying to keep the cache, worker alloc_caches should be
         * cleared and freed here. We do this after deleting workers to
         * guarantee that the alloc caches are valid throughout the lifetime
         * of workers. */
        if(!daemon->reuse_cache || daemon->need_to_exit)
                daemon_clear_allocs(daemon);
+       daemon->num = 0;
 #ifdef USE_DNSTAP
        dt_delete(daemon->dtenv);
        daemon->dtenv = NULL;