[vlc-devel] [RFC 37/38] stream_out/bridge: replaced usage of x{malloc, realloc}
Filip Roséen
filip at videolabs.io
Mon Jun 27 13:43:48 CEST 2016
---
modules/stream_out/bridge.c | 21 ++++++++++++++++++---
1 file changed, 18 insertions(+), 3 deletions(-)
diff --git a/modules/stream_out/bridge.c b/modules/stream_out/bridge.c
index 3e588a7..c38e5b4 100644
--- a/modules/stream_out/bridge.c
+++ b/modules/stream_out/bridge.c
@@ -252,7 +252,10 @@ static sout_stream_id_sys_t * AddOut( sout_stream_t *p_stream, const es_format_t
p_bridge = var_GetAddress( p_stream->obj.libvlc, p_sys->psz_name );
if ( p_bridge == NULL )
{
- p_bridge = xmalloc( sizeof( bridge_t ) );
+ p_bridge = malloc( sizeof( bridge_t ) );
+
+ if( unlikely( !p_bridge ) )
+ goto error;
var_Create( p_stream->obj.libvlc, p_sys->psz_name, VLC_VAR_ADDRESS );
var_SetAddress( p_stream->obj.libvlc, p_sys->psz_name, p_bridge );
@@ -269,10 +272,18 @@ static sout_stream_id_sys_t * AddOut( sout_stream_t *p_stream, const es_format_t
if ( i == p_bridge->i_es_num )
{
- p_bridge->pp_es = xrealloc( p_bridge->pp_es,
+ bridged_es_t ** pp_es_new = realloc( p_bridge->pp_es,
(p_bridge->i_es_num + 1) * sizeof(bridged_es_t *) );
+
+ if( unlikely( !pp_es_new ) )
+ goto error;
+
+ p_bridge->pp_es[i] = malloc( sizeof(bridged_es_t) );
+
+ if( unlikely( !p_bridge->pp_es[i] ) )
+ goto error;
+
p_bridge->i_es_num++;
- p_bridge->pp_es[i] = xmalloc( sizeof(bridged_es_t) );
}
p_sys->p_es = p_es = p_bridge->pp_es[i];
@@ -293,6 +304,10 @@ static sout_stream_id_sys_t * AddOut( sout_stream_t *p_stream, const es_format_t
vlc_mutex_unlock( &lock );
return (sout_stream_id_sys_t *)p_sys;
+
+error:
+ vlc_mutex_unlock( &lock );
+ return NULL;
}
static void DelOut( sout_stream_t *p_stream, sout_stream_id_sys_t *id )
--
2.9.0
More information about the vlc-devel
mailing list