Commit 5f3fe143 authored by Laurent Aimar's avatar Laurent Aimar

Fixed segfault in freetype after ToCharset() changes.

The code is quite ugly and the comments in IconvText() where wrongs...
parent 4b6e13d3
...@@ -1351,30 +1351,26 @@ static bool StyleEquals( ft_style_t *s1, ft_style_t *s2 ) ...@@ -1351,30 +1351,26 @@ static bool StyleEquals( ft_style_t *s1, ft_style_t *s2 )
static void IconvText( filter_t *p_filter, const char *psz_string, static void IconvText( filter_t *p_filter, const char *psz_string,
size_t *i_string_length, uint32_t **ppsz_unicode ) size_t *i_string_length, uint32_t **ppsz_unicode )
{ {
/* If memory hasn't been allocated for our output string, allocate it here *i_string_length = 0;
* - the calling function must now be responsible for freeing it. if( *ppsz_unicode == NULL )
*/ return;
if( !*ppsz_unicode )
*ppsz_unicode = (uint32_t *)
malloc( (strlen( psz_string ) + 1) * sizeof( uint32_t ));
/* We don't need to handle a NULL pointer in *ppsz_unicode
* if we are instead testing for a non NULL value like we are here */
if( *ppsz_unicode ) size_t i_length;
{ uint32_t *psz_tmp =
*ppsz_unicode =
#if defined(WORDS_BIGENDIAN) #if defined(WORDS_BIGENDIAN)
ToCharset( "UCS-4BE", psz_string, i_string_length ); ToCharset( "UCS-4BE", psz_string, &i_length );
#else #else
ToCharset( "UCS-4LE", psz_string, i_string_length ); ToCharset( "UCS-4LE", psz_string, &i_length );
#endif #endif
if( *ppsz_unicode != NULL ) if( !psz_tmp )
*i_string_length /= 4; {
else msg_Warn( p_filter, "failed to convert string to unicode (%m)" );
/* FIXME: This is going to fail miserably in the caller */ return;
msg_Warn( p_filter, "failed to convert string to unicode (%m)" );
} }
memcpy( *ppsz_unicode, psz_tmp, i_length );
*i_string_length = i_length / 4;
free( psz_tmp );
} }
static ft_style_t *GetStyleFromFontStack( filter_sys_t *p_sys, static ft_style_t *GetStyleFromFontStack( filter_sys_t *p_sys,
......
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