Opened 5 years ago
Closed 5 years ago
#1919 closed defect (duplicate)
Potential Memory Leak in directory 'src/core'. file 'ngx_hash.c.patch'
Reported by: | Owned by: | ||
---|---|---|---|
Priority: | minor | Milestone: | |
Component: | nginx-core | Version: | 1.15.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: | 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_hash.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:
--- ngx_hash.c.orig 2019-12-12 11:57:11.686837700 -0800
+++ ngx_hash.c 2019-12-12 12:02:06.045371000 -0800
@@ -696,12 +696,15 @@
ha->dns_wc_head_hash = ngx_pcalloc(ha->temp_pool,
sizeof(ngx_array_t) * ha->hsize);
if (ha->dns_wc_head_hash == NULL) {
+ ngx_pfree(ha->keys_hash); /* release previous memory allocation */
return NGX_ERROR;
}
ha->dns_wc_tail_hash = ngx_pcalloc(ha->temp_pool,
sizeof(ngx_array_t) * ha->hsize);
if (ha->dns_wc_tail_hash == NULL) {
+ ngx_pfree(ha->dns_wc_tail_hash); /* release tail_hash */
+ ngx_pfree(ha->keys_hash); /* release keys_hash */
return NGX_ERROR;
}
Change History (2)
by , 5 years ago
Attachment: | ngx_http_charset_filter_module.c.patch added |
---|
comment:1 by , 5 years ago
Resolution: | → duplicate |
---|---|
Status: | new → closed |
Duplicate of #1914.