From fff4475d912d32d2fa0ab1d114d54ddf5273586e Mon Sep 17 00:00:00 2001 From: Philippe Antoine Date: Fri, 6 Jan 2023 17:49:22 +0100 Subject: [PATCH] stream: fix memory leak when failing to insert segment As introduced by commit f848e34bcc266a2a4d8f5fc2661d2b430449b190 DoInsertSegment can now return `-EINVAL` and there was no generic handling of error values to return the tcp segment to its pool. Ticket: #5777 --- src/stream-tcp-list.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/stream-tcp-list.c b/src/stream-tcp-list.c index e5024e7338..9e3d27d12d 100644 --- a/src/stream-tcp-list.c +++ b/src/stream-tcp-list.c @@ -703,6 +703,9 @@ int StreamTcpReassembleInsertSegment(ThreadVars *tv, TcpReassemblyThreadCtx *ra_ } #endif } + } else { + // EINVAL + StreamTcpSegmentReturntoPool(seg); } SCReturnInt(0);