From e07d59c22e2386f96636f23ee5db27cce23ee21b Mon Sep 17 00:00:00 2001 From: lotherk Date: Wed, 18 Nov 2026 23:48:54 +0000 Subject: [PATCH] sse: free the reply content when the call array cannot be allocated The finish path hands a strdup'd content to the reply and then allocates the call array; if that allocation failed, the caller saw a failed reply and never freed the content. Out of memory only, but the analyzer found it and the free costs nothing. test_sse, test_engine and test_agent: ok. --- src/backend/sse.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/backend/sse.c b/src/backend/sse.c index fbfbe59..c2ce7a0 100644 --- a/src/backend/sse.c +++ b/src/backend/sse.c @@ -448,8 +448,13 @@ sp_sse_finish(struct sp_sse *s, struct sp_reply *out, struct sp_buf *err) return 0; out->calls = calloc(s->ncalls, sizeof(*out->calls)); - if (out->calls == NULL) + if (out->calls == NULL) { + /* the content is already in out; a failed reply is not freed by + * the caller, so it must be released here */ + free(out->content); + out->content = NULL; return -1; + } out->ncalls = s->ncalls; for (i = 0; i < s->ncalls; i++) { char idbuf[32];