From 3b73bdb160c97a77560231430938772c68c58bb9 Mon Sep 17 00:00:00 2001 From: =?utf8?q?R=C3=A9mi=20Denis-Courmont?= Date: Wed, 29 Oct 2008 22:27:10 +0200 Subject: [PATCH] Memory leak - fixes #2255 --- modules/misc/win32text.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/modules/misc/win32text.c b/modules/misc/win32text.c index b82e2a0df6..20c524e919 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 ) { -- 2.39.2