[PATCH] Increase size to sizeof(ngx_pool_t) if need when create pool

廖统浪 liaotonglang at gmail.com
Tue Dec 12 02:39:31 UTC 2017


# HG changeset patch
# User Liao Tonglang <liaotonglang at gmail.com>
# Date 1512991389 -28800
#      Mon Dec 11 19:23:09 2017 +0800
# Node ID 77be99f1a4766bf19761dfcf03531242923bd0a2
# Parent  d3235149d17f7745d3ac246a6cdcc81a56698f7b
Increase size to sizeof(ngx_pool_t) if need when create pool

If size is lesser than sizeof(ngx_pool_t), increase it's size to have enough
memory to store ngx_pool_t, or a coredump will occur.

diff -r d3235149d17f -r 77be99f1a476 src/core/ngx_palloc.c
--- a/src/core/ngx_palloc.c     Thu Dec 07 17:09:36 2017 +0300
+++ b/src/core/ngx_palloc.c     Mon Dec 11 19:23:09 2017 +0800
@@ -20,6 +20,10 @@
 {
     ngx_pool_t  *p;

+    if (size < sizeof(ngx_pool_t)) {
+        size = sizeof(ngx_pool_t);
+    }
+
     p = ngx_memalign(NGX_POOL_ALIGNMENT, size, log);
     if (p == NULL) {
         return NULL;
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/nginx-devel/attachments/20171212/c4fa4d77/attachment-0001.html>


More information about the nginx-devel mailing list