json-stream: refuse to attach already attached fds

json_stream_attach_fds() closes already attached fds.
Hence, the new fds must be different from the already attached ones.
This commit is contained in:
Yu Watanabe
2026-08-14 00:54:52 +09:00
parent 3e96a99bab
commit dc5de3fc03
+6
View File
@@ -220,6 +220,12 @@ int json_stream_attach_fds(JsonStream *s, int input_fd, int output_fd) {
struct stat st;
assert(s);
assert(input_fd >= 0);
assert(input_fd != s->input_fd);
assert(input_fd != s->output_fd);
assert(output_fd >= 0);
assert(output_fd != s->input_fd);
assert(output_fd != s->output_fd);
/* NB: input_fd and output_fd are donated to the JsonStream instance! */