summaryrefslogtreecommitdiff
path: root/src/openttd.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/openttd.cpp
parent6c7cbb1d46d266d33e49bd42a52e483296313882 (diff)
downloadopenttd-65637d89411e96dee5ee9fc2e8a7b3805c4162a2.tar.xz
(svn r22874) -Fix [FS#4747]: Check size of various buffers before allocation. (monoid)
Diffstat (limited to 'src/openttd.cpp')
-rw-r--r--src/openttd.cpp9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/openttd.cpp b/src/openttd.cpp
index 5cd5eba37..af1f77f4e 100644
--- a/src/openttd.cpp
+++ b/src/openttd.cpp
@@ -596,11 +596,12 @@ int ttd_main(int argc, char *argv[])
/*
* The width and height must be at least 1 pixel and width times
- * height must still fit within a 32 bits integer, this way all
- * internal drawing routines work correctly.
+ * height times bytes per pixel must still fit within a 32 bits
+ * integer, even for 32 bpp video modes. This way all internal
+ * drawing routines work correctly.
*/
- _cur_resolution.width = ClampU(_cur_resolution.width, 1, UINT16_MAX);
- _cur_resolution.height = ClampU(_cur_resolution.height, 1, UINT16_MAX);
+ _cur_resolution.width = ClampU(_cur_resolution.width, 1, UINT16_MAX / 2);
+ _cur_resolution.height = ClampU(_cur_resolution.height, 1, UINT16_MAX / 2);
/* enumerate language files */
InitializeLanguagePacks();