]> git.kaiwu.me - njs.git/commitdiff
A possible memory leak has been fixed.
authorIgor Sysoev <igor@sysoev.ru>
Mon, 31 Oct 2016 12:51:12 +0000 (15:51 +0300)
committerIgor Sysoev <igor@sysoev.ru>
Mon, 31 Oct 2016 12:51:12 +0000 (15:51 +0300)
Thanks to 洪志道 (Hong Zhi Dao).

nxt/nxt_mem_cache_pool.c

index 2dfe725c29b66e867dda00438a8154d1d3e82193..fcf68280dc3b18113752898c359dc75c47e1be33 100644 (file)
@@ -574,14 +574,13 @@ nxt_mem_cache_alloc_large(nxt_mem_cache_pool_t *pool, size_t alignment,
 
     } else {
         block = pool->proto->alloc(pool->mem, sizeof(nxt_mem_cache_block_t));
-
         if (nxt_slow_path(block == NULL)) {
-            pool->proto->free(pool->mem, block);
             return NULL;
         }
 
         p = pool->proto->align(pool->mem, alignment, size);
         if (nxt_slow_path(p == NULL)) {
+            pool->proto->free(pool->mem, block);
             return NULL;
         }