Skip to content

Commit

Permalink
fdpass: avoid memory leak in example.
Browse files Browse the repository at this point in the history
Signed-off-by: Rusty Russell <[email protected]>
  • Loading branch information
rustyrussell committed Apr 27, 2023
1 parent b8ab025 commit 0fad975
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion ccan/io/fdpass/_info
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,20 @@
* read_more, buf);
* }
*
* // Clean up allocation so -fsanitize=address doesn't see leak!
* static void free_buf(struct io_conn *c, struct buf *buf)
* {
* free(buf);
* }
*
* // Child has received fd, start reading loop.
* static struct io_plan *got_infd(struct io_conn *conn, int *infd)
* {
* struct buf *buf = calloc(1, sizeof(*buf));
* struct io_conn *new_conn;
*
* io_new_conn(NULL, *infd, read_more, buf);
* new_conn = io_new_conn(NULL, *infd, read_more, buf);
* io_set_finish(new_conn, free_buf, buf);
* return io_close(conn);
* }
* // Child is receiving the fd to read into.
Expand Down

0 comments on commit 0fad975

Please sign in to comment.