vlc/vlc-3.0 | branch: master | Thomas Guillem <tho...@gllm.fr> | Tue Mar  6 
16:02:01 2018 +0100| [8ca78afcbe3ddbe7b972834a1f414490ba7598fd] | committer: 
Thomas Guillem

vout: ios: fix leak in case of alloc failure

(cherry picked from commit b5a53bf515f3af89f6d77546dc95821ecd1c8a58)
Signed-off-by: Thomas Guillem <tho...@gllm.fr>

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

 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;
     }
 

_______________________________________________
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits

Reply via email to