[vlc-commits] smooth: memory leak

Rémi Denis-Courmont git at videolan.org
Tue Apr 22 22:46:31 CEST 2014


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Tue Apr 22 23:46:08 2014 +0300| [a43c6c8370fbbaeae5020fed136141590f48162c] | committer: Rémi Denis-Courmont

smooth: memory leak

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=a43c6c8370fbbaeae5020fed136141590f48162c
---

 modules/stream_filter/smooth/smooth.c |   42 +++++++++++++++------------------
 1 file changed, 19 insertions(+), 23 deletions(-)

diff --git a/modules/stream_filter/smooth/smooth.c b/modules/stream_filter/smooth/smooth.c
index dcb75ac..d4c73e0 100644
--- a/modules/stream_filter/smooth/smooth.c
+++ b/modules/stream_filter/smooth/smooth.c
@@ -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;
 }
 



More information about the vlc-commits mailing list