diff options
author | Russell King <rmk@armlinux.org.uk> | 2021-09-11 12:07:48 +0100 |
---|---|---|
committer | Russell King <rmk@armlinux.org.uk> | 2021-09-11 12:07:48 +0100 |
commit | 6201a11f03fe988a599a54f73c76640cac7e006e (patch) | |
tree | 269ddff40b4521e6b700f4b0fb5d53fc990e07f8 | |
parent | 42ccceaac9eef9a6a5387a4ffcf994e279e69573 (diff) |
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 <rmk@armlinux.org.uk>
-rw-r--r-- | event-httpd.c | 11 |
1 files changed, 10 insertions, 1 deletions
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, ' '); |