From 6201a11f03fe988a599a54f73c76640cac7e006e Mon Sep 17 00:00:00 2001 From: Russell King Date: Sat, 11 Sep 2021 12:07:48 +0100 Subject: event-httpd: free the line read from the client g_data_input_stream_read_line_finish() returns a string that needs to be freed when we are done with it. Ensure this happens. Signed-off-by: Russell King --- event-httpd.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/event-httpd.c b/event-httpd.c index 9943b14..1492fe4 100644 --- a/event-httpd.c +++ b/event-httpd.c @@ -107,6 +107,9 @@ static void update(GObject *source, GAsyncResult *res, gpointer user_data) } c->resource->update(c, c->resource, line); + + g_free(line); + g_data_input_stream_read_line_async(c->data, 0, NULL, update, c); } @@ -136,7 +139,9 @@ static void receive(GObject *source, GAsyncResult *res, gpointer user_data) // line(s) received where a Request-Line is expected. if (!c->request) { if (line[0]) - c->request = g_strdup(line); + c->request = line; + else + g_free(line); g_data_input_stream_read_line_async(c->data, 0, NULL, receive, c); @@ -150,11 +155,15 @@ static void receive(GObject *source, GAsyncResult *res, gpointer user_data) if (g_str_has_prefix(line, "X-Forwarded-")) c->forwarded = TRUE; + g_free(line); + g_data_input_stream_read_line_async(c->data, 0, NULL, receive, c); return; } + g_free(line); + // End of request. Parse it. // Find the URI uri = strchr(c->request, ' '); -- cgit