summaryrefslogtreecommitdiff
path: root/src/fontcache.cpp
diff options
context:
space:
mode:
authormichi_cc <michi_cc@openttd.org>2011-09-02 20:16:41 +0000
committermichi_cc <michi_cc@openttd.org>2011-09-02 20:16:41 +0000
commit65637d89411e96dee5ee9fc2e8a7b3805c4162a2 (patch)
tree79fdfb3cefba4457d3b81760173c5ca68e359a81 /src/fontcache.cpp
parent6c7cbb1d46d266d33e49bd42a52e483296313882 (diff)
downloadopenttd-65637d89411e96dee5ee9fc2e8a7b3805c4162a2.tar.xz
(svn r22874) -Fix [FS#4747]: Check size of various buffers before allocation. (monoid)
Diffstat (limited to 'src/fontcache.cpp')
-rw-r--r--src/fontcache.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/fontcache.cpp b/src/fontcache.cpp
index b279c3463..616c54a9e 100644
--- a/src/fontcache.cpp
+++ b/src/fontcache.cpp
@@ -1034,6 +1034,9 @@ const Sprite *GetGlyph(FontSize size, WChar key)
width = max(1, slot->bitmap.width + (size == FS_NORMAL));
height = max(1, slot->bitmap.rows + (size == FS_NORMAL));
+ /* Limit glyph size to prevent overflows later on. */
+ if (width > 256 || height > 256) usererror("Font glyph is too large");
+
/* FreeType has rendered the glyph, now we allocate a sprite and copy the image into it */
sprite.AllocateData(width * height);
sprite.width = width;