[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:57:51 CEST 2009


vlc | branch: 0.9-bugfix | Rémi Duraffort <ivoire at videolan.org> | Sun May 17 14:27:35 2009 +0200| [cc2fd42faf5f6192d12a83726481e70073284caa] | 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.

Signed-off-by: Rémi Duraffort <ivoire at videolan.org>
(cherry picked from commit c8829f3a7f6e4c9c9ebbd597b6443527a66bdfc4)

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

 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 c465fa4..ffb23a8 100644
--- a/modules/access/http.c
+++ b/modules/access/http.c
@@ -835,7 +835,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 );
@@ -1422,7 +1425,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. */
@@ -1432,7 +1438,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