#1914 closed defect (invalid)
Memory Leak in directory 'src/core', file 'ngx_buf.c'
Reported by: | Owned by: | ||
---|---|---|---|
Priority: | minor | Milestone: | |
Component: | nginx-core | Version: | 1.17.x |
Keywords: | potential memory leak(s) | Cc: | |
uname -a: | bill@foobar 4.4.0-18362-Microsoft #476-Microsoft Fri Nov 01 16:53:00 PST 2019 x86_64 GNU/Linux | ||
nginx -V: | version 1.15.0 (using static analysis of source code) |
Description
In reviewing source code in nginx-1.15.0, it would appear that there are some memory leaks in file 'ngx_buf.c' which when functions in this file are called, the memory allocations are not released, leading to over-utilization of memory over time, the patch file is below:
@@ -21,6 +21,7 @@
b->start = ngx_palloc(pool, size);
if (b->start == NULL) {
+ ngx_free(b); /* release previous memory allocation before going home */
return NULL;
}
@@ -84,7 +85,8 @@
b = ngx_calloc_buf(pool);
if (b == NULL) {
- return NULL;
+ ngx_free(p); /* release previous memory allocation and go home */
+ return NULL; /* how do we handle previous allocations of ngx_calloc_buf()? */
}
/*
Attachments (1)
Change History (7)
by , 5 years ago
Attachment: | ngx_buf.c.patch added |
---|
comment:1 by , 5 years ago
You seem to be missing the concepts of nginx memory management.
None of the tickets you just opened looks like actual leaks.
Please refer to:
http://nginx.org/en/docs/dev/development_guide.html#pool
comment:2 by , 5 years ago
Resolution: | → invalid |
---|---|
Status: | new → closed |
The code in question uses allocations from a memory pool, and all allocations are freed when the pool is destroyed. There is no need to do any explicit free operations. Further, the patch tries to call ngx_free()
, which is completely wrong, as this call is not memory pool aware.
Hope this helps. If you have further questions on nginx code, consider using mailing lists instead.
patch file for bug reported in ticket 1914