[vlc-devel] commit: (asf) check malloc return value (Jean-Paul Saman )
git version control
git at videolan.org
Mon Nov 24 15:06:38 CET 2008
vlc | branch: 0.8.6-bugfix | Jean-Paul Saman <jpsaman at videolan.org> | Mon Nov 24 13:48:00 2008 +0100| [524ffa322830b8db9f3dc4213039dcbbf8253e48] | committer: Jean-Paul Saman
(asf) check malloc return value
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=524ffa322830b8db9f3dc4213039dcbbf8253e48
---
modules/demux/asf/asf.c | 34 +++++++++++++++++++++++++---------
1 files changed, 25 insertions(+), 9 deletions(-)
diff --git a/modules/demux/asf/asf.c b/modules/demux/asf/asf.c
index 1fdfb44..58aaa90 100644
--- a/modules/demux/asf/asf.c
+++ b/modules/demux/asf/asf.c
@@ -2,7 +2,7 @@
* asf.c : ASF demux module
*****************************************************************************
* Copyright (C) 2002-2003 the VideoLAN team
- * $Id$
+ * $Id: 1fdfb44cf237d9af359af8c425a2303befd89e12 $
*
* Authors: Laurent Aimar <fenrir at via.ecp.fr>
*
@@ -118,6 +118,8 @@ static int Open( vlc_object_t * p_this )
p_demux->pf_demux = Demux;
p_demux->pf_control = Control;
p_demux->p_sys = p_sys = malloc( sizeof( demux_sys_t ) );
+ if( !p_sys )
+ return VLC_ENOMEM;
memset( p_sys, 0, sizeof( demux_sys_t ) );
/* Load the headers */
@@ -638,6 +640,8 @@ static int DemuxInit( demux_t *p_demux )
i_stream );
tk = p_sys->track[p_sp->i_stream_number] = malloc( sizeof( asf_track_t ) );
+ if( !tk )
+ goto error;
memset( tk, 0, sizeof( asf_track_t ) );
tk->i_time = -1;
@@ -680,8 +684,12 @@ static int DemuxInit( demux_t *p_demux )
p_sp->i_type_specific_data_length -
sizeof( WAVEFORMATEX ) );
fmt.p_extra = malloc( fmt.i_extra );
- memcpy( fmt.p_extra, &p_data[sizeof( WAVEFORMATEX )],
- fmt.i_extra );
+ if( fmt.p_extra )
+ {
+ memcpy( fmt.p_extra, &p_data[sizeof( WAVEFORMATEX )],
+ fmt.i_extra );
+ }
+ else fmt.i_extra = 0;
}
tk->i_cat = AUDIO_ES;
@@ -720,8 +728,12 @@ static int DemuxInit( demux_t *p_demux )
p_sp->i_type_specific_data_length - 11 -
sizeof( BITMAPINFOHEADER ) );
fmt.p_extra = malloc( fmt.i_extra );
- memcpy( fmt.p_extra, &p_data[sizeof( BITMAPINFOHEADER )],
- fmt.i_extra );
+ if( fmt.p_extra )
+ {
+ memcpy( fmt.p_extra, &p_data[sizeof( BITMAPINFOHEADER )],
+ fmt.i_extra );
+ }
+ else fmt.i_extra = 0;
}
/* Look for an aspect ratio */
@@ -755,7 +767,7 @@ static int DemuxInit( demux_t *p_demux )
(int64_t)fmt.video.i_width * VOUT_ASPECT_FACTOR /
fmt.video.i_height / i_aspect_y;
}
- }
+ }
tk->i_cat = VIDEO_ES;
tk->p_es = es_out_Add( p_demux->out, &fmt );
@@ -799,8 +811,12 @@ static int DemuxInit( demux_t *p_demux )
p_sp->i_type_specific_data_length -
sizeof( WAVEFORMATEX ) );
fmt.p_extra = malloc( fmt.i_extra );
- memcpy( fmt.p_extra, &p_data[sizeof( WAVEFORMATEX )],
- fmt.i_extra );
+ if( fmt.p_extra )
+ {
+ memcpy( fmt.p_extra, &p_data[sizeof( WAVEFORMATEX )],
+ fmt.i_extra );
+ }
+ else fmt.i_extra = 0;
}
tk->i_cat = AUDIO_ES;
@@ -958,7 +974,7 @@ static void DemuxEnd( demux_t *p_demux )
}
free( tk );
}
- p_sys->track[i] = 0;
+ p_sys->track[i] = NULL;
}
}
More information about the vlc-devel
mailing list