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