Bug 335972: nscoord -> short overflow in xft code leading to crash, patch by Phil Ringnalda <philringnalda@gmail.com> and Hein Roehrig <hroehrig@gmail.com>, r=bryner, sr=roc

This commit is contained in:
gavin%gavinsharp.com 2006-06-06 16:54:18 +00:00
parent 63879a6f99
commit 50e01a8983

View File

@ -2178,6 +2178,14 @@ nsAutoDrawSpecBuffer::Draw(nscoord x, nscoord y, XftFont *font, FT_UInt glyph)
if (mSpecPos >= BUFFER_LEN-1)
Flush();
// Make sure the coordinates fit into the 16-bit x and y fields of
// XftGlyphFontSpec
NS_ASSERTION(sizeof(short) == sizeof(mSpecBuffer[mSpecPos].x), "Unexpected coordinate type");
if ((short)x != x || (short)y != y){
NS_WARNING("ignoring coordinate overflow");
return;
}
mSpecBuffer[mSpecPos].x = x;
mSpecBuffer[mSpecPos].y = y;
mSpecBuffer[mSpecPos].font = font;