[Mplayer-cvslog] CVS: main/Gui/skin font.c,1.10,1.11

Jürgen Keil jkeil at mplayerhq.hu
Tue Sep 10 14:44:50 CEST 2002


Update of /cvsroot/mplayer/main/Gui/skin
In directory mail:/var/tmp.root/cvs-serv9377

Modified Files:
	font.c 
Log Message:
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.


Index: font.c
===================================================================
RCS file: /cvsroot/mplayer/main/Gui/skin/font.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- font.c	28 May 2002 11:55:17 -0000	1.10
+++ font.c	10 Sep 2002 12:44:47 -0000	1.11
@@ -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;




More information about the MPlayer-cvslog mailing list