[vlc-commits] mjpeg: probe before malloc in one simple case

Rémi Denis-Courmont git at videolan.org
Thu Aug 30 13:57:53 CEST 2012


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Thu Aug 30 14:57:14 2012 +0300| [e96daf834138eba8df15783b32883ebacb77df2b] | committer: Rémi Denis-Courmont

mjpeg: probe before malloc in one simple case

The code is still seriously brain damaged.

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

 modules/demux/mjpeg.c |   13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)

diff --git a/modules/demux/mjpeg.c b/modules/demux/mjpeg.c
index 8510a5c..ca62a21 100644
--- a/modules/demux/mjpeg.c
+++ b/modules/demux/mjpeg.c
@@ -324,11 +324,14 @@ static int SendBlock( demux_t *p_demux, int i )
 static int Open( vlc_object_t * p_this )
 {
     demux_t     *p_demux = (demux_t*)p_this;
-    demux_sys_t *p_sys;
     int         i_size;
     bool        b_matched = false;
 
-    p_sys = malloc( sizeof( demux_sys_t ) );
+    if( IsMxpeg( p_demux->s ) && !p_demux->b_force )
+        // let avformat handle this case
+        return VLC_EGENERIC;
+
+    demux_sys_t *p_sys = malloc( sizeof( demux_sys_t ) );
     if( unlikely(p_sys == NULL) )
         return VLC_ENOMEM;
 
@@ -341,12 +344,6 @@ static int Open( vlc_object_t * p_this )
     p_sys->psz_separator = NULL;
     p_sys->i_frame_size_estimate = 15 * 1024;
 
-    if( IsMxpeg( p_demux->s ) && !p_demux->b_force )
-    {
-        // let avformat handle this case
-        goto error;
-    }
-
     b_matched = CheckMimeHeader( p_demux, &i_size);
     if( b_matched )
     {



More information about the vlc-commits mailing list