]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
http server: fix memory leak in http_redirect (loc)
authorJaroslav Kysela <perex@perex.cz>
Thu, 16 Jun 2016 07:33:44 +0000 (09:33 +0200)
committerJaroslav Kysela <perex@perex.cz>
Thu, 16 Jun 2016 07:34:09 +0000 (09:34 +0200)
src/http.c

index 3d5d427405f1e9d807511f7574aaa1f4266f908b..3ccdea4081caeb3a44b3a9c8838cf0e458714c27 100644 (file)
@@ -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);
 }