]> git.sesse.net Git - vlc/commitdiff
Fix memleaks: EnsureUTF8 return NULL if the string isn't valid,
authorRémi Duraffort <ivoire@videolan.org>
Sun, 17 May 2009 12:27:35 +0000 (14:27 +0200)
committerRémi Duraffort <ivoire@videolan.org>
Sun, 17 May 2009 12:29:47 +0000 (14:29 +0200)
so we must be able to free the memory in this case.

modules/access/http.c

index 16544e1c3e2eda47dde3019c655b051ae3b24006..d6cb6334a8c2048fd85a47ddfc4a058608b669f0 100644 (file)
@@ -850,7 +850,10 @@ static int ReadICYMeta( access_t *p_access )
             strcmp( p_sys->psz_icy_title, &p[1] ) )
         {
             free( p_sys->psz_icy_title );
-            p_sys->psz_icy_title = EnsureUTF8( strdup( &p[1] ));
+            char *psz_tmp = strdup( &p[1] );
+            p_sys->psz_icy_title = EnsureUTF8( psz_tmp );
+            if( !p_sys->psz_icy_title )
+                free( psz_tmp );
             p_access->info.i_update |= INPUT_UPDATE_META;
 
             msg_Dbg( p_access, "New Title=%s", p_sys->psz_icy_title );
@@ -1432,7 +1435,10 @@ static int Request( access_t *p_access, int64_t i_tell )
         else if( !strcasecmp( psz, "Icy-Name" ) )
         {
             free( p_sys->psz_icy_name );
-            p_sys->psz_icy_name = EnsureUTF8( strdup( p ));
+            char *psz_tmp = strdup( p );
+            p_sys->psz_icy_name = EnsureUTF8( psz_tmp );
+            if( !p_sys->psz_icy_name )
+                free( psz_tmp );
             msg_Dbg( p_access, "Icy-Name: %s", p_sys->psz_icy_name );
 
             p_sys->b_icecast = true; /* be on the safeside. set it here as well. */
@@ -1442,7 +1448,10 @@ static int Request( access_t *p_access, int64_t i_tell )
         else if( !strcasecmp( psz, "Icy-Genre" ) )
         {
             free( p_sys->psz_icy_genre );
-            p_sys->psz_icy_genre = EnsureUTF8( strdup( p ));
+            char *psz_tmp = strdup( p );
+            p_sys->psz_icy_genre = EnsureUTF8( psz_tmp );
+            if( !p_sys->psz_icy_genre )
+                free( psz_tmp );
             msg_Dbg( p_access, "Icy-Genre: %s", p_sys->psz_icy_genre );
         }
         else if( !strncasecmp( psz, "Icy-Notice", 10 ) )