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.
This commit is contained in:
lotherk committed 2026-11-18 23:48:54 +00:00
1 parent 21287b88a9
commit e07d59c22e
1 file changed
+6 -1
+6 -1
View File
@@ -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];