]> git.sesse.net Git - vlc/commitdiff
Memory leak - fixes #2255
authorRémi Denis-Courmont <rdenis@simphalempin.com>
Wed, 29 Oct 2008 20:27:10 +0000 (22:27 +0200)
committerRémi Denis-Courmont <rdenis@simphalempin.com>
Wed, 29 Oct 2008 20:27:10 +0000 (22:27 +0200)
modules/misc/win32text.c

index b82e2a0df68c5da5f7563f6a5eb726a65ea9c89d..20c524e919418054382f257b99911fb00f9f5596 100644 (file)
@@ -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 )
     {