Opened 2 years ago

Closed 2 years ago

#1482 closed defect (fixed)

Memory leak in error handling block in ngx_stream_geo_block method

Reported by: keeplearning77@… Owned by: Ruslan Ermilov
Priority: minor Milestone:
Component: other Version: 1.13.x
Keywords: Cc:
uname -a:
nginx -V: nginx-1.13.8

Description

Source: nginx-1.13.8

File: nginx-1.13.8/src/stream/ngx_stream_geo_module.c

Function: static char *
ngx_stream_geo_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)

Code snippet:

...
...
pool = ngx_create_pool(NGX_DEFAULT_POOL_SIZE, cf->log);
if (pool == NULL) {

return NGX_CONF_ERROR;

}

ngx_memzero(&ctx, sizeof(ngx_stream_geo_conf_ctx_t));

ctx.temp_pool = ngx_create_pool(NGX_DEFAULT_POOL_SIZE, cf->log);
if (ctx.temp_pool == NULL) {

return NGX_CONF_ERROR;

}

...

Here, if the creation of ctx.temp_pool fails, shouldn't the "pool" variable created above be freed before return?

Change History (2)

comment:1 by Ruslan Ermilov, 2 years ago

Owner: set to Ruslan Ermilov
Status: newassigned

comment:2 by Ruslan Ermilov <ru@…>, 2 years ago

Resolution: fixed
Status: assignedclosed

In 7213:c69c13f10502/nginx:

Geo: fixed memory allocation error handling (closes #1482).

If during configuration parsing of the geo directive the memory
allocation has failed, pool used to parse configuration inside
the block, and sometimes the temporary pool were not destroyed.

Note: See TracTickets for help on using tickets.