[vlc-commits] remoteosd: close connection immediately if picture allocation fails

Rémi Denis-Courmont git at videolan.org
Thu Jul 9 20:34:19 CEST 2015


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Thu Jul  9 21:20:47 2015 +0300| [fc5b6ff9d375526f8ee972aad5ef86b0f5bad7e8] | committer: Rémi Denis-Courmont

remoteosd: close connection immediately if picture allocation fails

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

 modules/video_filter/remoteosd.c |   21 ++++++++++++---------
 1 file changed, 12 insertions(+), 9 deletions(-)

diff --git a/modules/video_filter/remoteosd.c b/modules/video_filter/remoteosd.c
index 6710576..8d6eae4 100644
--- a/modules/video_filter/remoteosd.c
+++ b/modules/video_filter/remoteosd.c
@@ -587,14 +587,19 @@ static void* vnc_worker_thread( void *obj )
     }
 
     /* Create an empty picture for VNC the data */
-    vlc_mutex_lock( &p_sys->lock );
-    p_sys->i_socket = fd;
-    p_sys->p_pic = picture_New( VLC_CODEC_YUVA,
-                                p_sys->i_vnc_width, p_sys->i_vnc_height, 1, 1 );
-    vlc_mutex_unlock( &p_sys->lock );
-    if( !p_sys->p_pic )
+    picture_t *pic =  picture_New( VLC_CODEC_YUVA, p_sys->i_vnc_width,
+                                   p_sys->i_vnc_height, 1, 1 );
+    if( likely(pic != NULL) )
+    {
+        vlc_mutex_lock( &p_sys->lock );
+        p_sys->i_socket = fd;
+        p_sys->p_pic = pic;
+        vlc_mutex_unlock( &p_sys->lock );
+    }
+    else
     {
-        goto exit;
+        net_Close( fd );
+        return NULL;
     }
 
     write_update_request( p_filter, false );
@@ -671,8 +676,6 @@ static void* vnc_worker_thread( void *obj )
         vlc_join( update_request_thread_handle, NULL );
     }
 
-exit:
-
     msg_Dbg( p_filter, "VNC message reader thread ended" );
     vlc_restorecancel (canc);
     return NULL;



More information about the vlc-commits mailing list