Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
http server: fix memory leak in http_redirect (loc)
  • Loading branch information
perexg committed Jun 16, 2016
1 parent 8f9aa30 commit 24bc73b
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/http.c
Expand Up @@ -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);
}
Expand All @@ -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);
}


Expand Down

0 comments on commit 24bc73b

Please sign in to comment.