[vlc-devel] commit: Fix memleaks: EnsureUTF8 return NULL if the string isn't valid, ( Rémi Duraffort )

git version control git at videolan.org
Sun May 17 14:31:59 CEST 2009


vlc | branch: 1.0-bugfix | Rémi Duraffort <ivoire at videolan.org> | Sun May 17 14:27:35 2009 +0200| [c8829f3a7f6e4c9c9ebbd597b6443527a66bdfc4] | committer: Rémi Duraffort 

Fix memleaks: EnsureUTF8 return NULL if the string isn't valid,
so we must be able to free the memory in this case.

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

 modules/access/http.c |   15 ++++++++++++---
 1 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/modules/access/http.c b/modules/access/http.c
index 16544e1..d6cb633 100644
--- a/modules/access/http.c
+++ b/modules/access/http.c
@@ -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 ) )




More information about the vlc-devel mailing list