From abd5fc025054af2bde355553e5307c94e994a8d9 Mon Sep 17 00:00:00 2001 From: Xavier Del Campo Romero Date: Sat, 31 Jan 2026 00:49:44 +0100 Subject: 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. --- handler.c | 3 +++ 1 file changed, 3 insertions(+) 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; } -- cgit v1.2.3