[vlc-commits] input: fix memory leak

Romain Vimont git at videolan.org
Thu Dec 19 10:51:19 CET 2019


vlc | branch: master | Romain Vimont <rom1v at videolabs.io> | Thu Dec 12 19:42:04 2019 +0100| [2c078da1192f5f869d0353643c2700c9d624adc8] | committer: Thomas Guillem

input: fix memory leak

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).

Signed-off-by: Thomas Guillem <thomas at gllm.fr>

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=2c078da1192f5f869d0353643c2700c9d624adc8
---

 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) )



More information about the vlc-commits mailing list