aboutsummaryrefslogtreecommitdiff
path: root/handler.c
diff options
context:
space:
mode:
authorXavier Del Campo Romero <xavi92@disroot.org>2026-01-31 00:49:44 +0100
committerXavier Del Campo Romero <xavi92@disroot.org>2026-01-31 23:16:16 +0100
commitabd5fc025054af2bde355553e5307c94e994a8d9 (patch)
tree8ee0748787b0b6623518aeb4832276f9aed63edb /handler.c
parent953210bd1930e1734f1acde86eadd7a1997bb7c3 (diff)
handler.c: Do not call free callback on failed payload
The free callback is meant to be executed whenever libweb fails to execute something and let the user deallocate any pending memory. However, the payload callback should deallocate user memory by itself on failure, since relying on the free payload for this purpose is not intuitive and fragile.
Diffstat (limited to 'handler.c')
-rw-r--r--handler.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/handler.c b/handler.c
index f30cfc3..455832b 100644
--- a/handler.c
+++ b/handler.c
@@ -75,6 +75,9 @@ static int on_payload(const struct http_payload *const p,
s->payload = r->step.payload;
c->args = r->args;
}
+ else
+ /* Avoid calling r->free again on exit. */
+ *r = (const struct http_response){0};
return ret;
}