Commit a43c6c83 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

smooth: memory leak

parent c84703a1
......@@ -72,41 +72,37 @@ static int Control( stream_t *, int , va_list );
static bool isSmoothStreaming( stream_t *s )
{
const uint8_t *peek;
const char *needle = "<SmoothStreamingMedia";
const char *encoding = NULL;
bool ret = false;
int i_size = stream_Peek( s->p_source, &peek, 512 );
if( i_size < 512 )
return false;
char *peeked = malloc( 512 );
if( unlikely( !peeked ) )
if( unlikely( peeked == NULL ) )
return false;
memcpy( peeked, peek, 512 );
peeked[511] = peeked[510] = '\0';
if( strstr( (const char *)peeked, needle ) != NULL )
ret = true;
else
/* maybe it's utf-16 encoding, should we also test other encodings? */
{
if( !memcmp( peeked, "\xFF\xFE", 2 ) )
encoding = "UTF-16LE";
else if( !memcmp( peeked, "\xFE\xFF", 2 ) )
encoding = "UTF-16BE";
else
{
free( peeked );
return false;
}
peeked = FromCharset( encoding, peeked, 512 );
char *str;
if( peeked != NULL && strstr( peeked, needle ) != NULL )
ret = true;
if( !memcmp( peeked, "\xFF\xFE", 2 ) )
{
str = FromCharset( "UTF-16LE", peeked, 512 );
free( peeked );
}
free( peeked );
else if( !memcmp( peeked, "\xFE\xFF", 2 ) )
{
str = FromCharset( "UTF-16BE", peeked, 512 );
free( peeked );
}
else
str = peeked;
if( str == NULL )
return false;
bool ret = strstr( str, "<SmoothStreamingMedia" ) != NULL;
free( str );
return ret;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment