]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
more_frags: check for basic blocks != NULL
authorMatthijs Mekking <matthijs@isc.org>
Tue, 4 Feb 2020 14:52:56 +0000 (15:52 +0100)
committerMatthijs Mekking <matthijs@isc.org>
Wed, 5 Feb 2020 08:08:35 +0000 (09:08 +0100)
lib/isc/mem.c

index b26d0fa653f5f31b73bf6235feb3fe11eec96b1f..ad3af97e96073856c95b214b0e473fbbb2293617 100644 (file)
@@ -342,7 +342,7 @@ quantize(size_t size) {
        return ((size + ALIGNMENT_SIZE - 1) & (~(ALIGNMENT_SIZE - 1)));
 }
 
-static inline bool
+static inline void
 more_basic_blocks(isc__mem_t *ctx) {
        void *tmp;
        unsigned char *curr, *next;
@@ -351,6 +351,11 @@ more_basic_blocks(isc__mem_t *ctx) {
        unsigned int table_size;
        int i;
 
+       if (ctx->basic_blocks != NULL) {
+               /* Nothing to do. */
+               return;
+       }
+
        /* Require: we hold the context lock. */
 
        INSIST(ctx->basic_table_count <= ctx->basic_table_size);
@@ -400,8 +405,6 @@ more_basic_blocks(isc__mem_t *ctx) {
        if (last > ctx->highest)
                ctx->highest = last;
        ctx->basic_blocks = tmp;
-
-       return (true);
 }
 
 static inline bool
@@ -415,17 +418,16 @@ more_frags(isc__mem_t *ctx, size_t new_size) {
         * Try to get more fragments by chopping up a basic block.
         */
 
+       more_basic_blocks(ctx);
        if (ctx->basic_blocks == NULL) {
-               if (!more_basic_blocks(ctx)) {
-                       /*
-                        * We can't get more memory from the OS, or we've
-                        * hit the quota for this context.
-                        */
-                       /*
-                        * XXXRTH  "At quota" notification here.
-                        */
-                       return (false);
-               }
+               /*
+                * We can't get more memory from the OS, or we've
+                * hit the quota for this context.
+                */
+               /*
+                * XXXRTH  "At quota" notification here.
+                */
+               return (false);
        }
 
        total_size = ctx->mem_target;