From cd115371b03138afaa8d4bfe6c72f2ed0ae8abdb Mon Sep 17 00:00:00 2001 From: Riccardo Magliocchetti Date: Wed, 14 Jan 2015 15:17:28 +0100 Subject: [PATCH] router_static: fix a couple of memory leaks Reported by Coverity as CID #1264352, #1264351 --- plugins/router_static/router_static.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/plugins/router_static/router_static.c b/plugins/router_static/router_static.c index 7ea438ad..14c5d8e2 100644 --- a/plugins/router_static/router_static.c +++ b/plugins/router_static/router_static.c @@ -141,7 +141,10 @@ int uwsgi_routing_func_sendfile(struct wsgi_request *wsgi_req, struct uwsgi_rout // static file - don't update avg_rt after request wsgi_req->do_not_account_avg_rt = 1; - if (urfc->no_headers) goto send; + if (urfc->no_headers) { + uwsgi_buffer_destroy(ub_s); + goto send; + } if (uwsgi_response_prepare_headers(wsgi_req, ub_s->buf, ub_s->pos)) { uwsgi_buffer_destroy(ub_s); @@ -211,7 +214,10 @@ int uwsgi_routing_func_fastfile(struct wsgi_request *wsgi_req, struct uwsgi_rout // static file - don't update avg_rt after request wsgi_req->do_not_account_avg_rt = 1; - if (urfc->no_headers) goto send; + if (urfc->no_headers) { + uwsgi_buffer_destroy(ub_s); + goto send; + } if (uwsgi_response_prepare_headers(wsgi_req, ub_s->buf, ub_s->pos)) { uwsgi_buffer_destroy(ub_s);