* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
#include <vlc/vlc.h>
#include "input_internal.h"
char psz_dup[strlen (psz_url) + 1];
strcpy (psz_dup, psz_url);;
- MRLSplit( p_parent, psz_dup, &psz_access, &psz_demux, &psz_path );
+ MRLSplit( psz_dup, &psz_access, &psz_demux, &psz_path );
/* Now try a real access */
p_access = access2_New( p_parent, psz_access, psz_demux, psz_path, 0 );
{
stream_t *s = vlc_stream_create( VLC_OBJECT(p_access) );
stream_sys_t *p_sys;
- char *psz_list;
+ char *psz_list = NULL;
if( !s ) return NULL;
s->pf_destroy = AStreamDestroy;
s->p_sys = p_sys = malloc( sizeof( stream_sys_t ) );
+ if( p_sys == NULL )
+ {
+ msg_Err( s, "Out of memory when allocating stream_sys_t" );
+ goto error;
+ }
/* UTF16 and UTF32 text file conversion */
s->i_char_width = 1;
if( (psz_list = var_CreateGetString( s, "input-list" )) && *psz_list )
{
access_entry_t *p_entry = malloc( sizeof(access_entry_t) );
+ if( p_entry == NULL )
+ {
+ msg_Err( s, "Out of memory when allocating access_entry_t" );
+ goto error;
+ }
char *psz_name, *psz_parser = psz_name = psz_list;
p_sys->p_list_access = p_access;
p_entry->i_size = p_access->info.i_size;
p_entry->psz_path = strdup( p_access->psz_path );
+ if( p_entry->psz_path == NULL )
+ {
+ msg_Err( s, "Out of memory when duplicating p_access->psz_path" );
+ free( p_entry );
+ goto error;
+ }
TAB_APPEND( p_sys->i_list, p_sys->list, p_entry );
msg_Dbg( p_access, "adding file `%s', ("I64Fd" bytes)",
p_entry->psz_path, p_access->info.i_size );
psz_name, p_tmp->info.i_size );
p_entry = malloc( sizeof(access_entry_t) );
+ if( p_entry == NULL )
+ {
+ msg_Err( p_access, "Out of memory when allocating access_entry_t" );
+ goto error;
+ }
p_entry->i_size = p_tmp->info.i_size;
p_entry->psz_path = psz_name;
TAB_APPEND( p_sys->i_list, p_sys->list, p_entry );
if( psz_name ) psz_name++;
}
}
- if( psz_list ) free( psz_list );
+ FREENULL( psz_list );
/* Peek */
p_sys->i_peek = 0;
p_sys->stream.i_offset = 0;
p_sys->stream.i_tk = 0;
p_sys->stream.p_buffer = malloc( STREAM_CACHE_SIZE );
+ if( p_sys->stream.p_buffer == NULL )
+ {
+ msg_Err( s, "Out of memory when allocating stream cache (%d bytes)",
+ STREAM_CACHE_SIZE );
+ goto error;
+ }
p_sys->stream.i_used = 0;
access2_Control( p_access, ACCESS_GET_MTU,
&p_sys->stream.i_read_size );
{
free( p_sys->stream.p_buffer );
}
+ while( p_sys->i_list > 0 )
+ free( p_sys->list[--(p_sys->i_list)] );
+ free( p_sys->list );
+ free( psz_list );
free( s->p_sys );
vlc_object_detach( s );
vlc_object_destroy( s );
}
return access2_vaControl( p_access, i_int, args );
+ case STREAM_GET_CONTENT_TYPE:
+ return access2_Control( p_access, ACCESS_GET_CONTENT_TYPE,
+ va_arg( args, char ** ) );
+
default:
msg_Err( s, "invalid stream_vaControl query=0x%x", i_query );
return VLC_EGENERIC;
/* Refill a block */
if( AStreamRefillBlock( s ) )
{
- msg_Err( s, "cannot re fill buffer" );
+ msg_Err( s, "cannot pre fill buffer" );
return VLC_EGENERIC;
}
/* Update stat */
var_SetString( p_input, "subsdec-encoding", "UTF-8" );
vlc_object_release( p_input );
}
- if( psz_encoding ) free( psz_encoding );
+ free( psz_encoding );
}
}
{
i_data = (psz_eol - (char *)p_data) + 1;
p_line = realloc( p_line, i_line + i_data + s->i_char_width ); /* add \0 */
+ if( !p_line )
+ {
+ msg_Err( s, "Out of memory when reallocating p_line" );
+ goto error;
+ }
i_data = stream_Read( s, &p_line[i_line], i_data );
if( i_data <= 0 ) break; /* Hmmm */
i_line += i_data - s->i_char_width; /* skip \n */;
/* Read data (+1 for easy \0 append) */
p_line = realloc( p_line, i_line + STREAM_PROBE_LINE + s->i_char_width );
+ if( !p_line )
+ {
+ msg_Err( s, "Out of memory when reallocating p_line" );
+ goto error;
+ }
i_data = stream_Read( s, &p_line[i_line], STREAM_PROBE_LINE );
if( i_data <= 0 ) break; /* Hmmm */
i_line += i_data;
/* iconv */
psz_new_line = malloc( i_line );
-
+ if( psz_new_line == NULL )
+ {
+ msg_Err( s, "Out of memory when allocating psz_new_line" );
+ goto error;
+ }
i_in = i_out = (size_t)i_line;
p_in = p_line;
p_out = psz_new_line;
return p_line;
}
+error:
+
/* We failed to read any data, probably EOF */
- if( p_line ) free( p_line );
+ free( p_line );
if( s->conv != (vlc_iconv_t)(-1) ) vlc_iconv_close( s->conv );
return NULL;
}