Mercurial > mplayer.hg
changeset 7353:0cb951ac0133
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.
author | jkeil |
---|---|
date | Tue, 10 Sep 2002 12:44:47 +0000 |
parents | 757e876d36fe |
children | 10c1cfc92981 |
files | Gui/skin/font.c |
diffstat | 1 files changed, 9 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/Gui/skin/font.c Tue Sep 10 12:38:19 2002 +0000 +++ b/Gui/skin/font.c Tue Sep 10 12:44:47 2002 +0000 @@ -119,7 +119,11 @@ if ( ( !Fonts[id] )||( !str[0] ) ) return 0; 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; } @@ -131,7 +135,10 @@ 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; } return max;