X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=modules%2Fmisc%2Fxml%2Fxtag.c;h=602c4e5a9ac49023ba927ab21bad82b810bb576d;hb=b9dc29f14cd4fb7898e8ee29de1707722523f63c;hp=e3b5193cbaccf77290a866a461aac03293dc28d5;hpb=3561b9b28f58eb7a4183e158a8fd973800d31ceb;p=vlc diff --git a/modules/misc/xml/xtag.c b/modules/misc/xml/xtag.c index e3b5193cba..602c4e5a9a 100644 --- a/modules/misc/xml/xtag.c +++ b/modules/misc/xml/xtag.c @@ -178,10 +178,8 @@ static xml_reader_t *ReaderCreate( xml_t *p_xml, stream_t *s ) /* Open and read file */ p_buffer = malloc( i_buffer ); - if( p_buffer == NULL ) { - msg_Err( p_xml, "out of memory" ); + if( p_buffer == NULL ) return NULL; - } while( ( i_size = stream_Read( s, &p_buffer[i_pos], 2048 ) ) == 2048 ) { @@ -190,7 +188,6 @@ static xml_reader_t *ReaderCreate( xml_t *p_xml, stream_t *s ) p_new = realloc( p_buffer, i_buffer ); if( !p_new ) { - msg_Err( p_xml, "out of memory" ); free( p_buffer ); return NULL; } @@ -297,7 +294,7 @@ static char *ReaderName( xml_reader_t *p_reader ) { psz_name = xtag_get_name( p_reader->p_sys->p_curtag ); #ifdef XTAG_DEBUG - printf( "TAG: %s\n", psz_name ); + fprintf( stderr, "TAG: %s\n", psz_name ); #endif } else @@ -313,7 +310,7 @@ static char *ReaderValue( xml_reader_t *p_reader ) if( p_reader->p_sys->p_curtag->pcdata ) { #ifdef XTAG_DEBUG - printf( "%s\n", p_reader->p_sys->p_curtag->pcdata ); + fprintf( stderr, "%s\n", p_reader->p_sys->p_curtag->pcdata ); #endif return strdup( p_reader->p_sys->p_curtag->pcdata ); } @@ -321,7 +318,7 @@ static char *ReaderValue( xml_reader_t *p_reader ) if( !p_reader->p_sys->p_curattr ) return 0; #ifdef XTAG_DEBUG - printf( "%s=%s\n", ((XAttribute *)p_reader->p_sys->p_curattr->data)->name, + fprintf( stderr, "%s=%s\n", ((XAttribute *)p_reader->p_sys->p_curattr->data)->name, ((XAttribute *)p_reader->p_sys->p_curattr->data)->value ); #endif @@ -534,7 +531,7 @@ static XAttribute *xtag_parse_attribute( XTagParser *parser ) if( !xtag_assert_and_pass( parser, X_EQUAL ) ) { #ifdef XTAG_DEBUG - printf( "xtag: attr failed EQUAL on <%s>\n", name ); + fprintf( stderr, "xtag: attr failed EQUAL on <%s>\n", name ); #endif goto err_free_name; } @@ -546,7 +543,7 @@ static XAttribute *xtag_parse_attribute( XTagParser *parser ) if( value == NULL ) { #ifdef XTAG_DEBUG - printf ("Got NULL quoted attribute value\n"); + fprintf (stderr, "Got NULL quoted attribute value\n"); #endif goto err_free_name; } @@ -647,7 +644,11 @@ static XTag *xtag_parse_tag( XTagParser *parser ) while (parser->end - s > 2) { if (strncmp( s, "]]>", 3 ) == 0) { if ( !(tag = malloc( sizeof(*tag))) ) return NULL; - if ( !(pcdata = malloc( sizeof(char)*(s - parser->start + 1))) ) return NULL; + if ( !(pcdata = malloc( sizeof(char)*(s - parser->start + 1))) ) + { + free( tag ); + return NULL; + } strncpy( pcdata, parser->start, s - parser->start ); pcdata[s - parser->start]='\0'; parser->start = s = &s[3]; @@ -672,7 +673,7 @@ static XTag *xtag_parse_tag( XTagParser *parser ) if( name == NULL ) return NULL; #ifdef XTAG_DEBUG - printf ("<%s ...\n", name); + fprintf (stderr, "<%s ...\n", name); #endif tag = malloc( sizeof(*tag) ); @@ -719,7 +720,7 @@ static XTag *xtag_parse_tag( XTagParser *parser ) if( strcmp( name, tag->name ) ) { #ifdef XTAG_DEBUG - printf ("got %s expected %s\n", name, tag->name); + fprintf (stderr, "got %s expected %s\n", name, tag->name); #endif parser->valid = false; } @@ -787,7 +788,7 @@ static XTag *xtag_new_parse( const char *s, int n ) else if( n == 0 ) { #ifdef XTAG_DEBUG - printf ("empty buffer"); + fprintf (stderr, "empty buffer\n"); #endif return NULL; } @@ -801,7 +802,7 @@ static XTag *xtag_new_parse( const char *s, int n ) if( !parser.valid ) { #ifdef XTAG_DEBUG - printf ("invalid file"); + fprintf (stderr, "invalid file\n"); #endif xtag_free( tag ); return NULL;