[vlc-commits] Check most demux_t.p_sys allocations

Rémi Denis-Courmont git at videolan.org
Mon Jul 11 21:29:47 CEST 2011


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Mon Jul 11 22:28:28 2011 +0300| [1cdbc7b6f2294024815f3d28128c8a7bf21156cb] | committer: Rémi Denis-Courmont

Check most demux_t.p_sys allocations

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

 modules/demux/cdg.c   |    6 +++++-
 modules/demux/flac.c  |    6 +++++-
 modules/demux/mjpeg.c |    6 +++++-
 modules/demux/nsv.c   |    6 +++++-
 modules/demux/pva.c   |    6 +++++-
 modules/demux/ty.c    |    6 +++++-
 modules/demux/vc1.c   |    6 +++++-
 modules/demux/xa.c    |    6 +++++-
 8 files changed, 40 insertions(+), 8 deletions(-)

diff --git a/modules/demux/cdg.c b/modules/demux/cdg.c
index c7a3b6e..e008757 100644
--- a/modules/demux/cdg.c
+++ b/modules/demux/cdg.c
@@ -86,9 +86,13 @@ static int Open( vlc_object_t * p_this )
 //        return VLC_EGENERIC;
 //    }
 
+    p_sys = malloc( sizeof( demux_sys_t ) );
+    if( unlikely(p_sys == NULL) )
+        return VLC_ENOMEM;
+
     p_demux->pf_demux   = Demux;
     p_demux->pf_control = Control;
-    p_demux->p_sys      = p_sys = malloc( sizeof( demux_sys_t ) );
+    p_demux->p_sys      = p_sys;
 
     /* */
     es_format_Init( &p_sys->fmt, VIDEO_ES, VLC_CODEC_CDG );
diff --git a/modules/demux/flac.c b/modules/demux/flac.c
index 898943d..0f01695 100644
--- a/modules/demux/flac.c
+++ b/modules/demux/flac.c
@@ -119,9 +119,13 @@ static int Open( vlc_object_t * p_this )
                  "continuing anyway" );
     }
 
+    p_sys = malloc( sizeof( demux_sys_t ) );
+    if( unlikely(p_sys == NULL) )
+        return VLC_ENOMEM;
+
     p_demux->pf_demux   = Demux;
     p_demux->pf_control = Control;
-    p_demux->p_sys      = p_sys = malloc( sizeof( demux_sys_t ) );
+    p_demux->p_sys      = p_sys;
     p_sys->b_start = true;
     p_sys->p_meta = NULL;
     memset( &p_sys->replay_gain, 0, sizeof(p_sys->replay_gain) );
diff --git a/modules/demux/mjpeg.c b/modules/demux/mjpeg.c
index 2ebb4a8..afdc484 100644
--- a/modules/demux/mjpeg.c
+++ b/modules/demux/mjpeg.c
@@ -303,8 +303,12 @@ static int Open( vlc_object_t * p_this )
     bool        b_matched = false;
     float       f_fps;
 
+    p_sys = malloc( sizeof( demux_sys_t ) );
+    if( unlikely(p_sys == NULL) )
+        return VLC_ENOMEM;
+
     p_demux->pf_control = Control;
-    p_demux->p_sys      = p_sys = malloc( sizeof( demux_sys_t ) );
+    p_demux->p_sys      = p_sys;
     p_sys->p_es         = NULL;
     p_sys->i_time       = 0;
     p_sys->i_level      = 0;
diff --git a/modules/demux/nsv.c b/modules/demux/nsv.c
index d81251d..017f511 100644
--- a/modules/demux/nsv.c
+++ b/modules/demux/nsv.c
@@ -104,10 +104,14 @@ static int Open( vlc_object_t *p_this )
             return VLC_EGENERIC;
     }
 
+    p_sys = malloc( sizeof( demux_sys_t ) );
+    if( unlikely(p_sys == NULL) )
+        return VLC_ENOMEM;
+
     /* Fill p_demux field */
+    p_demux->p_sys = p_sys;
     p_demux->pf_demux = Demux;
     p_demux->pf_control = Control;
-    p_demux->p_sys = p_sys = malloc( sizeof( demux_sys_t ) );
 
     es_format_Init( &p_sys->fmt_audio, AUDIO_ES, 0 );
     p_sys->p_audio = NULL;
diff --git a/modules/demux/pva.c b/modules/demux/pva.c
index f62b522..d25702d 100644
--- a/modules/demux/pva.c
+++ b/modules/demux/pva.c
@@ -92,10 +92,14 @@ static int Open( vlc_object_t *p_this )
             return VLC_EGENERIC;
     }
 
+    p_sys = malloc( sizeof( demux_sys_t ) );
+    if( unlikely(p_sys == NULL) )
+        return VLC_ENOMEM;
+
     /* Fill p_demux field */
     p_demux->pf_demux = Demux;
     p_demux->pf_control = Control;
-    p_demux->p_sys = p_sys = malloc( sizeof( demux_sys_t ) );
+    p_demux->p_sys = p_sys;
 
     /* Register one audio and one video stream */
     es_format_Init( &fmt, AUDIO_ES, VLC_CODEC_MPGA );
diff --git a/modules/demux/ty.c b/modules/demux/ty.c
index 75e2f3c..a9e0d2a 100644
--- a/modules/demux/ty.c
+++ b/modules/demux/ty.c
@@ -318,12 +318,16 @@ static int Open(vlc_object_t *p_this)
     /* at this point, we assume we have a valid TY stream */
     msg_Dbg( p_demux, "valid TY stream detected" );
 
+    p_sys = malloc(sizeof(demux_sys_t));
+    if( unlikely(p_sys == NULL) )
+        return VLC_ENOMEM;
+
     /* Set exported functions */
     p_demux->pf_demux = Demux;
     p_demux->pf_control = Control;
 
     /* create our structure that will hold all data */
-    p_demux->p_sys = p_sys = malloc(sizeof(demux_sys_t));
+    p_demux->p_sys = p_sys;
     memset(p_sys, 0, sizeof(demux_sys_t));
 
     /* set up our struct (most were zero'd out with the memset above) */
diff --git a/modules/demux/vc1.c b/modules/demux/vc1.c
index 0370455..bbc8203 100644
--- a/modules/demux/vc1.c
+++ b/modules/demux/vc1.c
@@ -96,9 +96,13 @@ static int Open( vlc_object_t * p_this )
                  "continuing anyway" );
     }
 
+    p_sys = malloc( sizeof( demux_sys_t ) );
+    if( unlikely(p_sys == NULL) )
+        return VLC_ENOMEM;
+
     p_demux->pf_demux  = Demux;
     p_demux->pf_control= Control;
-    p_demux->p_sys     = p_sys = malloc( sizeof( demux_sys_t ) );
+    p_demux->p_sys     = p_sys;
     p_sys->p_es        = NULL;
     p_sys->i_dts       = 0;
     p_sys->f_fps = var_CreateGetFloat( p_demux, "vc1-fps" );
diff --git a/modules/demux/xa.c b/modules/demux/xa.c
index a70f45a..3e25547 100644
--- a/modules/demux/xa.c
+++ b/modules/demux/xa.c
@@ -100,9 +100,13 @@ static int Open( vlc_object_t * p_this )
      || ( GetWLE( &p_xa.wBitsPerSample ) != 16) )
         return VLC_EGENERIC;
 
+    p_sys = malloc( sizeof( demux_sys_t ) );
+    if( unlikely( p_sys == NULL ) )
+        return VLC_ENOMEM;
+
     p_demux->pf_demux   = Demux;
     p_demux->pf_control = Control;
-    p_demux->p_sys      = p_sys = malloc( sizeof( demux_sys_t ) );
+    p_demux->p_sys      = p_sys;
     p_sys->p_es         = NULL;
 
     /* skip XA header -- cannot fail */



More information about the vlc-commits mailing list