aboutsummaryrefslogtreecommitdiff
path: root/http.c
diff options
context:
space:
mode:
authorXavier Del Campo Romero <xavi92@disroot.org>2025-10-08 01:51:15 +0200
committerXavier Del Campo Romero <xavi92@disroot.org>2025-10-08 01:57:42 +0200
commite85d90fbf37cbd5a3264a2debd9b51438836c729 (patch)
tree91099c585fe8c90f1d926f74734a1d23e3c65d64 /http.c
parent594917d7b2170f7e946e2cc7e9c5de3f6e4775be (diff)
downloadlibweb-e85d90fbf37cbd5a3264a2debd9b51438836c729.tar.gz
Free chunk/step user data on context free
So far, users had no way to free user-defined data allocated inside the chunk/step function pointers whenever an error occurred. Now, the free callback can be also used in conjunction with chunk/step, so that user-defined data is now deallocated when the operation finishes (in the case of chunk-encoded data) or an error occurs.
Diffstat (limited to 'http.c')
-rw-r--r--http.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/http.c b/http.c
index 21966bc..6410192 100644
--- a/http.c
+++ b/http.c
@@ -792,7 +792,7 @@ static int write_ctx_free(struct write_ctx *const w)
const struct http_response *const r = &w->r;
if (r->free)
- r->free(r->buf.rw);
+ r->free(r->args ? r->args : r->buf.rw);
if (r->f && (ret = fclose(r->f)))
fprintf(stderr, "%s: fclose(3): %s\n", __func__, strerror(errno));