[vlc-devel] [PATCH] input: fix memory leak

Romain Vimont rom1v at videolabs.io
Thu Dec 12 19:48:59 CET 2019


AppendAttachment() calls realloc() even with 0 attachment, but End()
does not call free() when i_attachment is 0, causing a memory leak
(reported by ASAN).
---
 src/input/input.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/src/input/input.c b/src/input/input.c
index b6ee5faf9e..977c230b23 100644
--- a/src/input/input.c
+++ b/src/input/input.c
@@ -2920,6 +2920,10 @@ static void AppendAttachment( int *pi_attachment, input_attachment_t ***ppp_atta
     int i_attachment = *pi_attachment;
     int i;
 
+    if ( i_attachment + i_new == 0 )
+        /* nothing to do */
+        return;
+
     input_attachment_t **pp_att = realloc( *ppp_attachment,
                     sizeof(*pp_att) * ( i_attachment + i_new ) );
     if( likely(pp_att) )
-- 
2.24.0



More information about the vlc-devel mailing list