[vlc-devel] [PATCH] core: playlist: Fix leak on allocation failure

Romain Vimont rom1v at videolabs.io
Fri Nov 16 11:43:50 CET 2018


If vlc_vector_push() returns false, then we keep ownership of the item,
so we must release it.
---
 src/playlist/preparse.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/playlist/preparse.c b/src/playlist/preparse.c
index 89e5da177a..5231f0646a 100644
--- a/src/playlist/preparse.c
+++ b/src/playlist/preparse.c
@@ -38,7 +38,10 @@ vlc_playlist_CollectChildren(playlist_item_vector_t *dest,
         input_item_node_t *child = node->pp_children[i];
         vlc_playlist_item_t *item = vlc_playlist_item_New(child->p_item);
         if (item)
-            vlc_vector_push(dest, item);
+        {
+            if (!vlc_vector_push(dest, item))
+                vlc_playlist_item_Release(item);
+        }
         vlc_playlist_CollectChildren(dest, child);
     }
 }
-- 
2.19.1



More information about the vlc-devel mailing list