From: Fredrik Tolf Date: Sat, 26 Feb 2011 14:49:55 +0000 (+0100) Subject: call[fs]cgi: Plugged a bit of memory leakage. X-Git-Tag: 0.7~4 X-Git-Url: http://www.dolda2000.com/gitweb/?p=ashd.git;a=commitdiff_plain;h=e25bf4f9646b5ee2cfe363fca67a32d4e2a3f0cc call[fs]cgi: Plugged a bit of memory leakage. --- 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++) {