From 522f3bb3a1f603bb2cf4a246a91c27789de66fb5 Mon Sep 17 00:00:00 2001 From: Riccardo Magliocchetti Date: Sat, 2 Nov 2013 16:17:53 +0100 Subject: [PATCH] plugins/xslt: fix xmlfile lifecycle Fixes an use after free and a memory leak. Reported by Coverity as CID #1125165, #1125167 --- plugins/xslt/xslt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/xslt/xslt.c b/plugins/xslt/xslt.c index 73bc936a..eda9eeb9 100644 --- a/plugins/xslt/xslt.c +++ b/plugins/xslt/xslt.c @@ -183,10 +183,9 @@ static int uwsgi_request_xslt(struct wsgi_request *wsgi_req) { return UWSGI_OK; } - free(xmlfile); - if (!uwsgi_is_file(filename)) { uwsgi_403(wsgi_req); + free(xmlfile); return UWSGI_OK; } filename_len = strlen(filename); @@ -276,6 +275,7 @@ apply: } // we have both the file and the stylesheet, let's run the engine xmlDoc *doc = xmlParseFile(xmlfile); + free(xmlfile); if (!doc) { uwsgi_500(wsgi_req); return UWSGI_OK;