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 )
FcResult fontresult = FcResultMatch;
#endif
/* 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 )
return VLC_ENOMEM;
#ifdef HAVE_FONTCONFIG
......@@ -339,15 +338,16 @@ static int Create( vlc_object_t *p_this )
GetWindowsDirectory( psz_fontfamily , PATH_MAX + 1 );
strcat( psz_fontfamily, "\\fonts\\arial.ttf" );
# else
strcpy( psz_fontfamily, DEFAULT_FONT );
strncpy( psz_fontfamily, DEFAULT_FONT, PATH_MAX );
# endif
msg_Err( p_filter,"User didn't specify fontfile, using %s", psz_fontfamily);
#endif
psz_fontfamily[PATH_MAX - 1] = '\0';
}
#ifdef HAVE_FONTCONFIG
/* 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 )
goto error;
......@@ -370,11 +370,10 @@ static int Create( vlc_object_t *p_this )
strcat( path, "\\fonts" );
if( p_dialog )
dialog_ProgressSet( p_dialog, NULL, 0.4 );
path[PATH_MAX - 1] = '\0';
FcConfigAppFontAddDir( NULL , path );
free(path);
if( p_dialog )
dialog_ProgressSet( p_dialog, NULL, 0.5 );
#endif
......@@ -389,7 +388,6 @@ static int Create( vlc_object_t *p_this )
msg_Dbg( p_filter, "Took %ld microseconds", (long)((t2 - t1)) );
fontpattern = FcPatternCreate();
if( !fontpattern )
{
msg_Err( p_filter, "Creating fontpattern failed");
......@@ -651,6 +649,12 @@ static int Render( filter_t *p_filter, subpicture_region_t *p_region,
if( !p_region->p_picture )
return VLC_EGENERIC;
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;
/* 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