From: Jaroslav Kysela Date: Thu, 16 Jun 2016 07:33:44 +0000 (+0200) Subject: http server: fix memory leak in http_redirect (loc) X-Git-Tag: v4.2.1~425 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=24bc73b94f1ab209669f31d443271d90d4717a62;p=thirdparty%2Ftvheadend.git http server: fix memory leak in http_redirect (loc) --- diff --git a/src/http.c b/src/http.c index 3d5d42740..3ccdea408 100644 --- a/src/http.c +++ b/src/http.c @@ -638,7 +638,7 @@ http_redirect(http_connection_t *hc, const char *location, loc = htsbuf_to_string(&hq); htsbuf_queue_flush(&hq); } else if (!external && tvheadend_webroot && location[0] == '/') { - loc = alloca(strlen(location) + strlen(tvheadend_webroot) + 1); + loc = malloc(strlen(location) + strlen(tvheadend_webroot) + 1); strcpy((char *)loc, tvheadend_webroot); strcat((char *)loc, location); } @@ -653,6 +653,9 @@ http_redirect(http_connection_t *hc, const char *location, loc, loc); http_send_reply(hc, HTTP_STATUS_FOUND, "text/html", NULL, loc, 0); + + if (loc != location) + free(loc); }