From ad5a271b0d3bd39021e1c3acc6c77577c2d8f56a Mon Sep 17 00:00:00 2001 From: jthomas43 <129407891+jthomas43@users.noreply.github.com> Date: Sat, 5 Oct 2024 03:19:07 -0400 Subject: [PATCH] fix: leak out-of-order packet if the read callback destroys the stream (#213) --- src/udx.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/udx.c b/src/udx.c index 8db7d31..89e1aa8 100644 --- a/src/udx.c +++ b/src/udx.c @@ -1305,7 +1305,10 @@ process_packet (udx_socket_t *socket, char *buf, ssize_t buf_len, struct sockadd if ((pkt->type & UDX_HEADER_DATA) && stream->on_read != NULL) { stream->on_read(stream, pkt->buf.len, &(pkt->buf)); - if (stream->status & UDX_STREAM_DEAD) return 1; + if (stream->status & UDX_STREAM_DEAD) { + free(pkt); + return 1; + } } free(pkt);