[vlc-devel] [PATCH] asx: fix SEGV when input isn't UTF8 or can't be XML encoded
Pierre Lamot
pierre at videolabs.io
Thu Feb 1 11:46:05 CET 2018
---
modules/demux/playlist/asx.c | 27 +++++++++++++++------------
1 file changed, 15 insertions(+), 12 deletions(-)
diff --git a/modules/demux/playlist/asx.c b/modules/demux/playlist/asx.c
index c4d7170013..385785ad01 100644
--- a/modules/demux/playlist/asx.c
+++ b/modules/demux/playlist/asx.c
@@ -423,6 +423,11 @@ static void memstream_puts_xmlencoded(struct vlc_memstream* p_stream, const char
else
{
char *psz_tmp_encoded = vlc_xml_encode( psz_tmp );
+ if ( !psz_tmp_encoded )
+ {
+ free( psz_tmp );
+ return;
+ }
vlc_memstream_puts( p_stream, psz_tmp_encoded );
free( psz_tmp_encoded );
}
@@ -547,23 +552,21 @@ static stream_t* PreparseStream( stream_t *p_demux )
} while ( streamSize > 0 );
psz_source[i_read] = 0;
+ if( !IsUTF8( psz_source ) )
+ {
+ char *psz_utf8 = FromLatin1( psz_source );
+ free( psz_source );
+ if( psz_utf8 == NULL )
+ return NULL;
+ psz_source = psz_utf8;
+ }
+
char* psz_source_xml = ASXToXML( psz_source );
free( psz_source );
if( psz_source_xml == NULL )
return NULL;
- if( IsUTF8( psz_source_xml ) )
- return vlc_stream_MemoryNew( p_demux, (uint8_t*)psz_source_xml, strlen(psz_source_xml), false );
-
- char *psz_utf8 = FromLatin1( psz_source_xml );
- if( psz_utf8 == NULL )
- {
- free( psz_source_xml );
- return NULL;
- }
-
- stream_t * p_stream = vlc_stream_MemoryNew( p_demux, (uint8_t*)psz_utf8, strlen(psz_utf8), false );
- free( psz_source_xml );
+ stream_t * p_stream = vlc_stream_MemoryNew( p_demux, (uint8_t*)psz_source_xml, strlen(psz_source_xml), false );
return p_stream;
}
--
2.14.1
More information about the vlc-devel
mailing list