Opened 7 months ago

Closed 7 months ago

#1918 closed defect (duplicate)

Potential Memory Leak in directory 'src/http/modules'. file 'ngx_http_auth_request_module.c'

Reported by: wp02855@… Owned by:
Priority: minor Milestone:
Component: nginx-module 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_http_auth_request_module.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_http_charset_filter_module.c.orig 2019-12-12 12:45:49.023069600 -0800
+++ ngx_http_charset_filter_module.c 2019-12-12 13:47:06.566471000 -0800
@@ -1112,6 +1112,7 @@

cl->buf = ngx_calloc_buf(pool);
if (cl->buf == NULL) {

+ ngx_free_chain(cl); /* release memory allocated to cl */

return NULL;

}


@@ -1229,11 +1230,14 @@

table->dst2src = ngx_pcalloc(cf->pool, 256 * sizeof(void *));
if (table->dst2src == NULL) {

+ ngx_pfree(table->src2dst); /* release memory allocated to table->src2dst */

return NGX_CONF_ERROR;

}


dst2src = ngx_pcalloc(cf->pool, 256);
if (dst2src == NULL) {

+ ngx_pfree(table->dst2src); /* release memory allocated to table->dst2src */
+ ngx_pfree(table->src2dst); /* release memory allocated to table->src2dst */

return NGX_CONF_ERROR;

}


@@ -1665,6 +1669,7 @@

if (dst == NULL) {

dst = ngx_pcalloc(cf->pool, sizeof(u_char *) * mcf->charsets.nelts);
if (dst == NULL) {

+ ngx_pfree(src); /* release memory allocated to src */

return NGX_ERROR;

}

Change History (1)

comment:1 by Maxim Dounin, 7 months ago

Resolution: duplicate
Status: newclosed

Duplicate of #1914.

Note: See TracTickets for help on using tickets.