Commit 837ce238 authored by Jean-Paul Saman's avatar Jean-Paul Saman

freetype: various fixes

- zero terminate strings
- fix potential memleak
parent 4a33ee31
...@@ -300,9 +300,8 @@ static int Create( vlc_object_t *p_this ) ...@@ -300,9 +300,8 @@ static int Create( vlc_object_t *p_this )
FcResult fontresult = FcResultMatch; FcResult fontresult = FcResultMatch;
#endif #endif
/* Allocate structure */ /* Allocate structure */
p_filter->p_sys = p_sys = malloc( sizeof( filter_sys_t ) ); p_filter->p_sys = p_sys = calloc( 1, sizeof( filter_sys_t ) );
if( !p_sys ) if( !p_sys )
return VLC_ENOMEM; return VLC_ENOMEM;
#ifdef HAVE_FONTCONFIG #ifdef HAVE_FONTCONFIG
...@@ -339,15 +338,16 @@ static int Create( vlc_object_t *p_this ) ...@@ -339,15 +338,16 @@ static int Create( vlc_object_t *p_this )
GetWindowsDirectory( psz_fontfamily , PATH_MAX + 1 ); GetWindowsDirectory( psz_fontfamily , PATH_MAX + 1 );
strcat( psz_fontfamily, "\\fonts\\arial.ttf" ); strcat( psz_fontfamily, "\\fonts\\arial.ttf" );
# else # else
strcpy( psz_fontfamily, DEFAULT_FONT ); strncpy( psz_fontfamily, DEFAULT_FONT, PATH_MAX );
# endif # endif
msg_Err( p_filter,"User didn't specify fontfile, using %s", psz_fontfamily); msg_Err( p_filter,"User didn't specify fontfile, using %s", psz_fontfamily);
#endif #endif
psz_fontfamily[PATH_MAX - 1] = '\0';
} }
#ifdef HAVE_FONTCONFIG #ifdef HAVE_FONTCONFIG
/* Lets find some fontfile from freetype-font variable family */ /* Lets find some fontfile from freetype-font variable family */
char *psz_fontsize; char *psz_fontsize = NULL;
if( asprintf( &psz_fontsize, "%d", p_sys->i_default_font_size ) == -1 ) if( asprintf( &psz_fontsize, "%d", p_sys->i_default_font_size ) == -1 )
goto error; goto error;
...@@ -370,11 +370,10 @@ static int Create( vlc_object_t *p_this ) ...@@ -370,11 +370,10 @@ static int Create( vlc_object_t *p_this )
strcat( path, "\\fonts" ); strcat( path, "\\fonts" );
if( p_dialog ) if( p_dialog )
dialog_ProgressSet( p_dialog, NULL, 0.4 ); dialog_ProgressSet( p_dialog, NULL, 0.4 );
path[PATH_MAX - 1] = '\0';
FcConfigAppFontAddDir( NULL , path ); FcConfigAppFontAddDir( NULL , path );
free(path); free(path);
if( p_dialog ) if( p_dialog )
dialog_ProgressSet( p_dialog, NULL, 0.5 ); dialog_ProgressSet( p_dialog, NULL, 0.5 );
#endif #endif
...@@ -389,7 +388,6 @@ static int Create( vlc_object_t *p_this ) ...@@ -389,7 +388,6 @@ static int Create( vlc_object_t *p_this )
msg_Dbg( p_filter, "Took %ld microseconds", (long)((t2 - t1)) ); msg_Dbg( p_filter, "Took %ld microseconds", (long)((t2 - t1)) );
fontpattern = FcPatternCreate(); fontpattern = FcPatternCreate();
if( !fontpattern ) if( !fontpattern )
{ {
msg_Err( p_filter, "Creating fontpattern failed"); msg_Err( p_filter, "Creating fontpattern failed");
...@@ -651,6 +649,12 @@ static int Render( filter_t *p_filter, subpicture_region_t *p_region, ...@@ -651,6 +649,12 @@ static int Render( filter_t *p_filter, subpicture_region_t *p_region,
if( !p_region->p_picture ) if( !p_region->p_picture )
return VLC_EGENERIC; return VLC_EGENERIC;
fmt.p_palette = p_region->fmt.p_palette ? p_region->fmt.p_palette : malloc(sizeof(*fmt.p_palette)); fmt.p_palette = p_region->fmt.p_palette ? p_region->fmt.p_palette : malloc(sizeof(*fmt.p_palette));
if( !fmt.p_palette )
{
picture_Delete( p_region->p_picture );
p_region->p_picture = NULL;
return VLC_ENOMEM;
}
p_region->fmt = fmt; p_region->fmt = fmt;
/* Calculate text color components */ /* Calculate text color components */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment