Opened 7 months ago

Closed 7 months ago

#1919 closed defect (duplicate)

Potential Memory Leak in directory 'src/core'. file 'ngx_hash.c.patch'

Reported by: wp02855@… 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;

}

Attachments (1)

ngx_http_charset_filter_module.c.patch (1.1 KB ) - added by wp02855@… 7 months ago.

Download all attachments as: .zip

Change History (2)

by wp02855@…, 7 months ago

comment:1 by Maxim Dounin, 7 months ago

Resolution: duplicate
Status: newclosed

Duplicate of #1914.

Note: See TracTickets for help on using tickets.