[vlc-devel] commit: Memory leak - fixes #2255 ( Rémi Denis-Courmont )

git version control git at videolan.org
Wed Oct 29 21:27:23 CET 2008


vlc | branch: master | Rémi Denis-Courmont <rdenis at simphalempin.com> | Wed Oct 29 22:27:10 2008 +0200| [3b73bdb160c97a77560231430938772c68c58bb9] | committer: Rémi Denis-Courmont 

Memory leak - fixes #2255

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

 modules/misc/win32text.c |   12 +++++++++---
 1 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/modules/misc/win32text.c b/modules/misc/win32text.c
index b82e2a0..20c524e 100644
--- a/modules/misc/win32text.c
+++ b/modules/misc/win32text.c
@@ -301,8 +301,10 @@ static int RenderText( filter_t *p_filter, subpicture_region_t *p_region_out,
 
     /* Sanity check */
     if( !p_region_in || !p_region_out ) return VLC_EGENERIC;
-#ifdef UNICODE
     psz_string = malloc( (strlen( p_region_in->psz_text )+1) * sizeof(TCHAR) );
+    if( !psz_string )
+        return VLC_ENOMEM;
+#ifdef UNICODE
     if( mbstowcs( psz_string, p_region_in->psz_text,
                   strlen( p_region_in->psz_text ) * sizeof(TCHAR) ) < 0 )
     {
@@ -310,9 +312,13 @@ static int RenderText( filter_t *p_filter, subpicture_region_t *p_region_out,
         return VLC_EGENERIC;
     }
 #else
-    psz_string = strdup( p_region_in->psz_text );
+    strcpy( psz_string, p_region_in->psz_text );
 #endif
-    if( !psz_string || !*psz_string ) return VLC_EGENERIC;
+    if( !*psz_string )
+    {
+        free( psz_strin );
+        return VLC_EGENERIC;
+    }
 
     if( p_region_in->p_style )
     {




More information about the vlc-devel mailing list