From c8829f3a7f6e4c9c9ebbd597b6443527a66bdfc4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Duraffort?= <ivoire@videolan.org> Date: Sun, 17 May 2009 14:27:35 +0200 Subject: [PATCH] Fix memleaks: EnsureUTF8 return NULL if the string isn't valid, so we must be able to free the memory in this case. --- modules/access/http.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/modules/access/http.c b/modules/access/http.c index 16544e1c3e..d6cb6334a8 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 ) ) -- 2.25.4