[vlc-commits] vout: ios: fix leak in case of alloc failure

Thomas Guillem git at videolan.org
Wed Mar 7 15:34:17 CET 2018


vlc | branch: master | Thomas Guillem <thomas at gllm.fr> | Tue Mar  6 16:02:01 2018 +0100| [b5a53bf515f3af89f6d77546dc95821ecd1c8a58] | committer: Thomas Guillem

vout: ios: fix leak in case of alloc failure

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

 modules/video_output/ios.m | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/modules/video_output/ios.m b/modules/video_output/ios.m
index 7c761b5e6a..2c56d22d25 100644
--- a/modules/video_output/ios.m
+++ b/modules/video_output/ios.m
@@ -385,17 +385,15 @@ static void GLESSwap(vlc_gl_t *gl)
 
 - (id)initWithFrameAndVd:(CGRect)frame withVd:(vout_display_t*)vd
 {
-    self = [super initWithFrame:frame];
-
-    if (!self)
-        return nil;
-
     _appActive = ([UIApplication sharedApplication].applicationState == UIApplicationStateActive);
     if (unlikely(!_appActive))
         return nil;
 
-    _bufferNeedReset = YES;
+    self = [super initWithFrame:frame];
+    if (!self)
+        return nil;
 
+    _bufferNeedReset = YES;
     _voutDisplay = vd;
     _cfg = *_voutDisplay->cfg;
 
@@ -412,9 +410,13 @@ static void GLESSwap(vlc_gl_t *gl)
     if (unlikely(!_eaglContext)
      || unlikely(![EAGLContext setCurrentContext:_eaglContext]))
     {
+        if (_eaglContext)
+            [_eaglContext release];
         vlc_mutex_destroy(&_mutex);
+        [super dealloc];
         return nil;
     }
+    [self releaseCurrent:previousEaglContext];
 
     _layer = (CAEAGLLayer *)self.layer;
     _layer.drawableProperties = [NSDictionary dictionaryWithObject:kEAGLColorFormatRGBA8 forKey: kEAGLDrawablePropertyColorFormat];
@@ -422,12 +424,11 @@ static void GLESSwap(vlc_gl_t *gl)
 
     self.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
 
-    [self releaseCurrent:previousEaglContext];
-
     if (![self fetchViewContainer])
     {
         vlc_mutex_destroy(&_mutex);
         [_eaglContext release];
+        [super dealloc];
         return nil;
     }
 



More information about the vlc-commits mailing list