]> git.ipfire.org Git - thirdparty/unbound.git/commitdiff
- Fix for out-of-memory condition in libunbound (thanks Robert Fleischman).
authorWouter Wijngaards <wouter@nlnetlabs.nl>
Fri, 14 Oct 2011 07:15:41 +0000 (07:15 +0000)
committerWouter Wijngaards <wouter@nlnetlabs.nl>
Fri, 14 Oct 2011 07:15:41 +0000 (07:15 +0000)
git-svn-id: file:///svn/unbound/trunk@2511 be551aaa-1e26-0410-a405-d3ace91eadb9

doc/Changelog
libunbound/libworker.c

index c90f6e34a94058f4f14b37f2daad49afa9bdc693..a7daa18b7f2347bea4277ae6294c9b100fec1056 100644 (file)
@@ -1,3 +1,7 @@
+14 October 2011: Wouter
+       - Fix for out-of-memory condition in libunbound (thanks
+         Robert Fleischman).
+
 13 October 2011: Wouter
        - Fix --enable-allsymbols, it depended on link specifics of the
          target platform, or fptr_wlist assertion failures could occur.
index 673d3430f1e2c9046d7511f8a04258658639fc53..6aa19e203311557a852a561cbd7757329570eb9d 100644 (file)
@@ -261,7 +261,12 @@ libworker_dobg(void* arg)
        /* setup */
        uint32_t m;
        struct libworker* w = (struct libworker*)arg;
-       struct ub_ctx* ctx = w->ctx;
+       struct ub_ctx* ctx;
+       if(!w) {
+               log_err("libunbound bg worker init failed, nomem");
+               return NULL;
+       }
+       ctx = w->ctx;
        log_thread_set(&w->thread_num);
 #ifdef THREADS_DISABLED
        /* we are forked */
@@ -270,10 +275,6 @@ libworker_dobg(void* arg)
        tube_close_write(ctx->qq_pipe);
        tube_close_read(ctx->rr_pipe);
 #endif
-       if(!w) {
-               log_err("libunbound bg worker init failed, nomem");
-               return NULL;
-       }
        if(!tube_setup_bg_listen(ctx->qq_pipe, w->base, 
                libworker_handle_control_cmd, w)) {
                log_err("libunbound bg worker init failed, no bglisten");
@@ -310,11 +311,11 @@ int libworker_bg(struct ub_ctx* ctx)
        if(ctx->dothread) {
                lock_basic_unlock(&ctx->cfglock);
                w = libworker_setup(ctx, 1);
+               if(!w) return UB_NOMEM;
                w->is_bg_thread = 1;
 #ifdef ENABLE_LOCK_CHECKS
                w->thread_num = 1; /* for nicer DEBUG checklocks */
 #endif
-               if(!w) return UB_NOMEM;
                ub_thread_create(&ctx->bg_tid, libworker_dobg, w);
        } else {
                lock_basic_unlock(&ctx->cfglock);