mirror of https://github.com/mpv-player/mpv
Use the character substitution code from fntRender() / fntTextWidth()
for non-existant characters in fntTextHeight(), too. Otherwise the image height is mis-computed and we allocate an output image that is too small; this could result in malloc heap corruption. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@7354 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
parent
9088ca28e9
commit
fb3b95bc3a
|
@ -119,7 +119,11 @@ int fntTextWidth( int id,char * str )
|
||||||
if ( ( !Fonts[id] )||( !str[0] ) ) return 0;
|
if ( ( !Fonts[id] )||( !str[0] ) ) return 0;
|
||||||
|
|
||||||
for ( i=0;i < (unsigned int)strlen( str );i++ )
|
for ( i=0;i < (unsigned int)strlen( str );i++ )
|
||||||
size+=( Fonts[id]->Fnt[ (unsigned char)str[i] ].sx == -1? Fonts[id]->Fnt[ 32 ].sx : Fonts[id]->Fnt[ (unsigned char)str[i] ].sx );
|
{
|
||||||
|
unsigned char c = (unsigned char)str[i];
|
||||||
|
if ( Fonts[id]->Fnt[c].sx == -1 ) c = ' ';
|
||||||
|
size+= Fonts[id]->Fnt[ c ].sx;
|
||||||
|
}
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -131,7 +135,10 @@ int fntTextHeight( int id,char * str )
|
||||||
|
|
||||||
for ( i=0;i < (int)strlen( str );i++ )
|
for ( i=0;i < (int)strlen( str );i++ )
|
||||||
{
|
{
|
||||||
int h = Fonts[id]->Fnt[ (unsigned char)str[i] ].sy;
|
int h;
|
||||||
|
unsigned char c = (unsigned char)str[i];
|
||||||
|
if ( Fonts[id]->Fnt[c].sx == -1 ) c = ' ';
|
||||||
|
h = Fonts[id]->Fnt[c].sy;
|
||||||
if ( h > max ) max=h;
|
if ( h > max ) max=h;
|
||||||
}
|
}
|
||||||
return max;
|
return max;
|
||||||
|
|
Loading…
Reference in New Issue