From e25bf4f9646b5ee2cfe363fca67a32d4e2a3f0cc Mon Sep 17 00:00:00 2001 From: Fredrik Tolf Date: Sat, 26 Feb 2011 15:49:55 +0100 Subject: [PATCH] call[fs]cgi: Plugged a bit of memory leakage. --- src/callfcgi.c | 8 ++++++-- src/callscgi.c | 8 ++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/callfcgi.c b/src/callfcgi.c index 9a7a362..1ff521e 100644 --- a/src/callfcgi.c +++ b/src/callfcgi.c @@ -465,6 +465,7 @@ static void mkcgienv(struct hthead *req, struct charbuf *dst) } else { bufaddenv(dst, "SCRIPT_NAME", "%s", url); } + free(url); bufaddenv(dst, "QUERY_STRING", "%s", qp?qp:""); if((h = getheader(req, "Host")) != NULL) bufaddenv(dst, "SERVER_NAME", "%s", h); @@ -482,8 +483,11 @@ static void mkcgienv(struct hthead *req, struct charbuf *dst) bufaddenv(dst, "CONTENT_LENGTH", "%s", h); else bufaddenv(dst, "CONTENT_LENGTH", "0"); - if((h = getheader(req, "X-Ash-File")) != NULL) - bufaddenv(dst, "SCRIPT_FILENAME", "%s", absolutify(h)); + if((h = getheader(req, "X-Ash-File")) != NULL) { + h = absolutify(h); + bufaddenv(dst, "SCRIPT_FILENAME", "%s", h); + free(h); + } for(i = 0; i < req->noheaders; i++) { h = sprintf2("HTTP_%s", req->headers[i][0]); for(p = h; *p; p++) { diff --git a/src/callscgi.c b/src/callscgi.c index 84b63c5..e91759e 100644 --- a/src/callscgi.c +++ b/src/callscgi.c @@ -428,6 +428,7 @@ static void mkcgienv(struct hthead *req, struct charbuf *dst) } else { bufaddenv(dst, "SCRIPT_NAME", "%s", url); } + free(url); bufaddenv(dst, "QUERY_STRING", "%s", qp?qp:""); if((h = getheader(req, "Host")) != NULL) bufaddenv(dst, "SERVER_NAME", "%s", h); @@ -445,8 +446,11 @@ static void mkcgienv(struct hthead *req, struct charbuf *dst) bufaddenv(dst, "CONTENT_LENGTH", "%s", h); else bufaddenv(dst, "CONTENT_LENGTH", "0"); - if((h = getheader(req, "X-Ash-File")) != NULL) - bufaddenv(dst, "SCRIPT_FILENAME", "%s", absolutify(h)); + if((h = getheader(req, "X-Ash-File")) != NULL) { + h = absolutify(h); + bufaddenv(dst, "SCRIPT_FILENAME", "%s", h); + free(h); + } for(i = 0; i < req->noheaders; i++) { h = sprintf2("HTTP_%s", req->headers[i][0]); for(p = h; *p; p++) { -- 2.11.0