[vlc-devel] [RFC 24/38] demux/avformat: replaced usage of xmalloc
Filip Roséen
filip at videolabs.io
Mon Jun 27 13:43:35 CEST 2016
---
modules/demux/avformat/demux.c | 21 ++++++++++++++++++---
1 file changed, 18 insertions(+), 3 deletions(-)
diff --git a/modules/demux/avformat/demux.c b/modules/demux/avformat/demux.c
index a00b3e4..5258179 100644
--- a/modules/demux/avformat/demux.c
+++ b/modules/demux/avformat/demux.c
@@ -275,7 +275,14 @@ int OpenDemux( vlc_object_t *p_this )
/* Fill p_demux fields */
p_demux->pf_demux = Demux;
p_demux->pf_control = Control;
- p_demux->p_sys = p_sys = xmalloc( sizeof( demux_sys_t ) );
+ p_demux->p_sys = p_sys = malloc( sizeof( demux_sys_t ) );
+
+ if( unlikely( !p_sys ) )
+ {
+ free( psz_url );
+ return VLC_ENOMEM;
+ }
+
p_sys->ic = 0;
p_sys->fmt = fmt;
p_sys->i_tk = 0;
@@ -1062,7 +1069,11 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
return VLC_EGENERIC;
*pi_int = p_sys->i_attachments;;
- *ppp_attach = xmalloc( sizeof(input_attachment_t*) * p_sys->i_attachments );
+ *ppp_attach = malloc( sizeof(input_attachment_t*) * p_sys->i_attachments );
+
+ if( unlikely( !*ppp_attach ) )
+ return VLC_ENOMEM;
+
for( i = 0; i < p_sys->i_attachments; i++ )
(*ppp_attach)[i] = vlc_input_attachment_Duplicate( p_sys->attachments[i] );
return VLC_SUCCESS;
@@ -1079,7 +1090,11 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
return VLC_EGENERIC;
*pi_int = 1;
- *ppp_title = xmalloc( sizeof( input_title_t*) );
+ *ppp_title = malloc( sizeof( input_title_t*) );
+
+ if( unlikely( !*ppp_title ) )
+ return VLC_ENOMEM;
+
(*ppp_title)[0] = vlc_input_title_Duplicate( p_sys->p_title );
*pi_title_offset = 0;
*pi_seekpoint_offset = 0;
--
2.9.0
More information about the vlc-devel
mailing list