[vlc-devel] [PATCH 01/14] videotoolbox: fix leak in ExtradataInfoCreate

Marvin Scholz epirat07 at gmail.com
Fri Jul 3 04:27:31 CEST 2020


If p_data is null, the already created extradataInfo was leaked.
Check p_data first and error out early to prevent even creating
the extradataInfo if its never used.
---
 modules/codec/videotoolbox.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/modules/codec/videotoolbox.c b/modules/codec/videotoolbox.c
index 4a0912cb08..30d3d330ac 100644
--- a/modules/codec/videotoolbox.c
+++ b/modules/codec/videotoolbox.c
@@ -1627,11 +1627,11 @@ static int ConfigureVout(decoder_t *p_dec)
 static CFMutableDictionaryRef ExtradataInfoCreate(CFStringRef name,
                                                   void *p_data, size_t i_data)
 {
-    CFMutableDictionaryRef extradataInfo = cfdict_create(1);
-    if (extradataInfo == NULL)
+    if (p_data == NULL)
         return NULL;
 
-    if (p_data == NULL)
+    CFMutableDictionaryRef extradataInfo = cfdict_create(1);
+    if (extradataInfo == NULL)
         return NULL;
 
     CFDataRef extradata = CFDataCreate(kCFAllocatorDefault, p_data, i_data);
-- 
2.24.3 (Apple Git-128)



More information about the vlc-devel mailing list