nginx-upstream-fair icon indicating copy to clipboard operation
nginx-upstream-fair copied to clipboard

Memory leak?

Open mikegagnon opened this issue 12 years ago • 2 comments

In ngx_http_upstream_fair_module.c, beginning on line 604

/* setup our wrapper around rr */
peers = ngx_palloc(cf->pool, sizeof *peers);
if (peers == NULL) {
    return NGX_ERROR;
}
peers = us->peer.data;

Looks like a bug to allocate memory to peers then immediately re-assign peers to something else. I'm not familiar with nginx code base, so I apologize if this is correct and I am misunderstanding something.

mikegagnon avatar Mar 11 '12 22:03 mikegagnon

Indeed, it looks dumb. I haven't looked at this code for a very long time so I cannot tell you right now what it should be..

But still, the allocation is not a leak thanks to Nginx pools.

gnosek avatar Mar 12 '12 07:03 gnosek

indeed,I checked the code . so there is no need to do this:peers = ngx_palloc(cf->pool, sizeof *peers);

fankeke avatar May 27 '15 05:05 fankeke