/*****************************************************************************
* Preamble
*****************************************************************************/
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
#include <vlc/vlc.h>
/* 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 ) );
+ if( p_sys == NULL )
+ {
+ return VLC_ENOMEM;
+ }
memset( p_sys, 0, sizeof( demux_sys_t ) );
+
p_sys->i_data_offset = 0;
p_sys->i_track = 0;
p_sys->track = NULL;
free( tk );
}
- if( p_sys->psz_title ) free( p_sys->psz_title );
- if( p_sys->psz_artist ) free( p_sys->psz_artist );
- if( p_sys->psz_copyright ) free( p_sys->psz_copyright );
- if( p_sys->psz_description ) free( p_sys->psz_description );
+ free( p_sys->psz_title );
+ free( p_sys->psz_artist );
+ free( p_sys->psz_copyright );
+ free( p_sys->psz_description );
if( p_sys->i_track > 0 ) free( p_sys->track );
free( p_sys );
stream_Read( p_demux->s, psz, i_len );
psz[i_len] = '\0';
- msg_Dbg( p_demux, " - title=`%s'", psz );
EnsureUTF8( psz );
- asprintf( &p_sys->psz_title, psz );
- free( psz );
+ msg_Dbg( p_demux, " - title=`%s'", psz );
+ p_sys->psz_title = psz;
i_skip -= i_len;
}
i_skip -= 2;
stream_Read( p_demux->s, psz, i_len );
psz[i_len] = '\0';
- msg_Dbg( p_demux, " - author=`%s'", psz );
EnsureUTF8( psz );
- asprintf( &p_sys->psz_artist, psz );
- free( psz );
+ msg_Dbg( p_demux, " - author=`%s'", psz );
+ p_sys->psz_artist = psz;
i_skip -= i_len;
}
i_skip -= 2;
stream_Read( p_demux->s, psz, i_len );
psz[i_len] = '\0';
- msg_Dbg( p_demux, " - copyright=`%s'", psz );
EnsureUTF8( psz );
- asprintf( &p_sys->psz_copyright, psz );
- free( psz );
+ msg_Dbg( p_demux, " - copyright=`%s'", psz );
+ p_sys->psz_copyright = psz;
i_skip -= i_len;
}
i_skip -= 2;
stream_Read( p_demux->s, psz, i_len );
psz[i_len] = '\0';
- msg_Dbg( p_demux, " - comment=`%s'", psz );
EnsureUTF8( psz );
- asprintf( &p_sys->psz_description, psz );
- free( psz );
+ msg_Dbg( p_demux, " - comment=`%s'", psz );
+ p_sys->psz_description = psz;
i_skip -= i_len;
}
i_skip -= 2;
memcpy( psz, p_peek, i_len );
psz[i_len] = '\0';
- msg_Dbg( p_demux, " - title=`%s'", psz );
EnsureUTF8( psz );
- asprintf( &p_sys->psz_title, psz );
- free( psz );
+ msg_Dbg( p_demux, " - title=`%s'", psz );
+ p_sys->psz_title = psz;
}
p_peek += i_len;
memcpy( psz, p_peek, i_len );
psz[i_len] = '\0';
- msg_Dbg( p_demux, " - artist=`%s'", psz );
EnsureUTF8( psz );
- asprintf( &p_sys->psz_artist, psz );
- free( psz );
+ msg_Dbg( p_demux, " - artist=`%s'", psz );
+ p_sys->psz_artist = psz;
}
p_peek += i_len;
memcpy( psz, p_peek, i_len );
psz[i_len] = '\0';
- msg_Dbg( p_demux, " - Copyright=`%s'", psz );
EnsureUTF8( psz );
- asprintf( &p_sys->psz_copyright, psz );
- free( psz );
+ msg_Dbg( p_demux, " - Copyright=`%s'", psz );
+ p_sys->psz_copyright = psz;
}
p_peek += i_len;
memcpy( psz, p_peek, i_len );
psz[i_len] = '\0';
- msg_Dbg( p_demux, " - Comment=`%s'", psz );
EnsureUTF8( psz );
- asprintf( &p_sys->psz_description, psz );
- free( psz );
+ msg_Dbg( p_demux, " - Comment=`%s'", psz );
+ p_sys->psz_description = psz;
}
/* This might be unusefull */
p_peek += i_len;
i_subpacket_h = GetWBE( p_peek ); p_peek += 2; /* 1 */
i_frame_size = GetWBE( p_peek ); p_peek += 2; /* frame size */
i_subpacket_size = GetWBE( p_peek ); p_peek += 2; /* subpacket_size */
+ if( !i_subpacket_size || !i_frame_size || !i_coded_frame_size )
+ return VLC_EGENERIC;
p_peek += 2; /* ?? */
if( i_version == 5 ) p_peek += 6; /* 0, srate, 0 */
case VLC_FOURCC( 'r','a','a','c' ):
case VLC_FOURCC( 'r','a','c','p' ):
+ fmt.i_codec = VLC_FOURCC( 'm','p','4','a' );
+
if( fmt.i_extra > 0 ) { fmt.i_extra--; p_peek++; }
if( fmt.i_extra > 0 )
{
fmt.p_extra = malloc( fmt.i_extra );
+ if( fmt.p_extra == NULL )
+ {
+ msg_Err( p_demux, "Error in the extra data" );
+ return VLC_EGENERIC;
+ }
memcpy( fmt.p_extra, p_peek, fmt.i_extra );
}
-
- fmt.i_codec = VLC_FOURCC( 'm','p','4','a' );
break;
case VLC_FOURCC('s','i','p','r'):
fmt.audio.i_blockalign = i_subpacket_size;
else
fmt.audio.i_blockalign = i_coded_frame_size;
- if( !fmt.i_extra ) break;
- fmt.p_extra = malloc( fmt.i_extra );
- memcpy( fmt.p_extra, p_peek, fmt.i_extra );
+
+ if( fmt.i_extra > 0 )
+ {
+ fmt.p_extra = malloc( fmt.i_extra );
+ if( fmt.p_extra == NULL )
+ {
+ msg_Err( p_demux, "Error in the extra data" );
+ return VLC_EGENERIC;
+ }
+ memcpy( fmt.p_extra, p_peek, fmt.i_extra );
+ }
break;
case VLC_FOURCC('r','a','l','f'):
tk->i_subpackets =
i_subpacket_h * i_frame_size / tk->i_subpacket_size;
tk->p_subpackets =
- malloc( tk->i_subpackets * sizeof(block_t *) );
+ calloc( tk->i_subpackets, sizeof(block_t *) );
}
else if( fmt.i_codec == VLC_FOURCC('2','8','_','8') )
{
tk->i_subpackets =
i_subpacket_h * i_frame_size / tk->i_coded_frame_size;
tk->p_subpackets =
- malloc( tk->i_subpackets * sizeof(block_t *) );
+ calloc( tk->i_subpackets, sizeof(block_t *) );
}
- for( i = 0; i < tk->i_subpackets; i++ ) tk->p_subpackets[i] = NULL;
+ /* Check if the calloc went correctly */
+ if( tk->p_subpackets == NULL )
+ {
+ tk->i_subpackets = 0;
+ msg_Err( p_demux, "Can't alloc subpacket" );
+ return VLC_EGENERIC;
+ }
tk->p_es = es_out_Add( p_demux->out, &fmt );