]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
expand the pool then copy over the old entries so we that failures do not break the...
authorMark Andrews <marka@isc.org>
Fri, 19 Oct 2018 08:36:17 +0000 (19:36 +1100)
committerMark Andrews <marka@isc.org>
Thu, 25 Oct 2018 02:00:08 +0000 (22:00 -0400)
lib/isc/pool.c

index 5c693a6eea7e2a395f0f64e84fcdf08b5afcf60e..8fb2a45e24949aa8a8587915df57dad30e679dc4 100644 (file)
@@ -131,21 +131,22 @@ isc_pool_expand(isc_pool_t **sourcep, unsigned int count,
                newpool->init = pool->init;
                newpool->initarg = pool->initarg;
 
-               /* Copy over the objects from the old pool */
-               for (i = 0; i < pool->count; i++) {
-                       newpool->pool[i] = pool->pool[i];
-                       pool->pool[i] = NULL;
-               }
-
                /* Populate the new entries */
                for (i = pool->count; i < count; i++) {
-                       result = pool->init(&newpool->pool[i], pool->initarg);
+                       result = newpool->init(&newpool->pool[i],
+                                              newpool->initarg);
                        if (result != ISC_R_SUCCESS) {
-                               isc_pool_destroy(&pool);
+                               isc_pool_destroy(&newpool);
                                return (result);
                        }
                }
 
+               /* Copy over the objects from the old pool */
+               for (i = 0; i < pool->count; i++) {
+                       newpool->pool[i] = pool->pool[i];
+                       pool->pool[i] = NULL;
+               }
+
                isc_pool_destroy(&pool);
                pool = newpool;
        }