summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2013-11-25 13:06:33 +0000
committerrubidium <rubidium@openttd.org>2013-11-25 13:06:33 +0000
commitf817b06c18dbded20fa01a0e38b81b4eefa7c1a6 (patch)
treeb04f801896690d910ec5211b35b291cb3bcc663c
parente106e54f9fa96905ccbbb4f205a473ec3ce6d9a3 (diff)
downloadopenttd-f817b06c18dbded20fa01a0e38b81b4eefa7c1a6.tar.xz
(svn r26103) -Fix: prevent odd overflows due to integer promotion
-rw-r--r--src/blitter/32bpp_simple.cpp2
-rw-r--r--src/blitter/8bpp_simple.cpp2
2 files changed, 2 insertions, 2 deletions
diff --git a/src/blitter/32bpp_simple.cpp b/src/blitter/32bpp_simple.cpp
index 539d26ff0..4a9036a13 100644
--- a/src/blitter/32bpp_simple.cpp
+++ b/src/blitter/32bpp_simple.cpp
@@ -95,7 +95,7 @@ void Blitter_32bppSimple::DrawColourMappingRect(void *dst, int width, int height
Sprite *Blitter_32bppSimple::Encode(const SpriteLoader::Sprite *sprite, AllocatorProc *allocator)
{
Blitter_32bppSimple::Pixel *dst;
- Sprite *dest_sprite = (Sprite *)allocator(sizeof(*dest_sprite) + sprite->height * sprite->width * sizeof(*dst));
+ Sprite *dest_sprite = (Sprite *)allocator(sizeof(*dest_sprite) + (size_t)sprite->height * (size_t)sprite->width * sizeof(*dst));
dest_sprite->height = sprite->height;
dest_sprite->width = sprite->width;
diff --git a/src/blitter/8bpp_simple.cpp b/src/blitter/8bpp_simple.cpp
index 1d405e0ee..d1bd316bb 100644
--- a/src/blitter/8bpp_simple.cpp
+++ b/src/blitter/8bpp_simple.cpp
@@ -58,7 +58,7 @@ void Blitter_8bppSimple::Draw(Blitter::BlitterParams *bp, BlitterMode mode, Zoom
Sprite *Blitter_8bppSimple::Encode(const SpriteLoader::Sprite *sprite, AllocatorProc *allocator)
{
Sprite *dest_sprite;
- dest_sprite = (Sprite *)allocator(sizeof(*dest_sprite) + sprite->height * sprite->width);
+ dest_sprite = (Sprite *)allocator(sizeof(*dest_sprite) + (size_t)sprite->height * (size_t)sprite->width);
dest_sprite->height = sprite->height;
dest_sprite->width = sprite->width;