[PATCH] channel_curl: Fix memory leak in channel_set_content_type

12 views
Skip to first unread message

Shota Shimoyama

unread,
Sep 23, 2026, 9:25:24 PMSep 23
to swup...@googlegroups.com
channel_set_content_type() uses asprintf() to dynamically allocate
memory for the HTTP header strings. However, after passing these strings
to curl_slist_append() (which creates its own internal copy),
the allocated memory buffers were not freed.

Fix this by explicitly calling free() on contenttype and accept
once they have been added to the header list.

Reviewed-by: Dominique Martinet <dominique...@atmark-techno.com>
Signed-off-by: Shota Shimoyama <shota.s...@atmark-techno.com>
---
corelib/channel_curl.c | 2 ++
1 file changed, 2 insertions(+)

diff --git a/corelib/channel_curl.c b/corelib/channel_curl.c
index bae44d85..4474c94c 100644
--- a/corelib/channel_curl.c
+++ b/corelib/channel_curl.c
@@ -559,6 +559,7 @@ static channel_op_res_t channel_set_content_type(channel_t *this,
ERROR("Setting channel header Content-type failed.");
result = CHANNEL_EINIT;
}
+ free(contenttype);
}

if (channel_data->accept_content_type)
@@ -572,6 +573,7 @@ static channel_op_res_t channel_set_content_type(channel_t *this,
ERROR("Setting channel header Accept failed.");
result = CHANNEL_EINIT;
}
+ free(accept);
}

return result;
--
2.34.1

Stefano Babic

unread,
Sep 28, 2026, 6:33:04 AM (10 days ago) Sep 28
to Shota Shimoyama, swup...@googlegroups.com
Reviewed-by: Stefano Babic <stefan...@swupdate.org>


--
_______________________________________________________________________
Nabla Software Engineering GmbH
Hirschstr. 111A | 86156 Augsburg | Tel: +49 821 45592596
Geschäftsführer : Stefano Babic | HRB 40522 Augsburg
E-Mail: sba...@nabladev.com

Reply all
Reply to author
Forward
0 new messages