aboutsummaryrefslogtreecommitdiff
path: root/engines/sword25
diff options
context:
space:
mode:
authorSven Hesse2011-01-24 14:59:21 +0000
committerSven Hesse2011-01-24 14:59:21 +0000
commitffb3de5bc05cbc9ef1c7431bf43f157d30f17c00 (patch)
treef3c38ce2a6d765fd456894b8074ce32678033f34 /engines/sword25
parent9eea8c6bca530e48e8c1725b3829de189f2aec0e (diff)
downloadscummvm-rg350-ffb3de5bc05cbc9ef1c7431bf43f157d30f17c00.tar.gz
scummvm-rg350-ffb3de5bc05cbc9ef1c7431bf43f157d30f17c00.tar.bz2
scummvm-rg350-ffb3de5bc05cbc9ef1c7431bf43f157d30f17c00.zip
SWORD25: Fix some invalid writes / crashes
On my system, sizeof(png_uint_32) == 8, while sizeof(int) == 4. svn-id: r55504
Diffstat (limited to 'engines/sword25')
-rw-r--r--engines/sword25/gfx/image/pngloader.cpp16
1 files changed, 13 insertions, 3 deletions
diff --git a/engines/sword25/gfx/image/pngloader.cpp b/engines/sword25/gfx/image/pngloader.cpp
index f104372f78..cdff0012c2 100644
--- a/engines/sword25/gfx/image/pngloader.cpp
+++ b/engines/sword25/gfx/image/pngloader.cpp
@@ -131,7 +131,11 @@ bool PNGLoader::doDecodeImage(const byte *fileDataPtr, uint fileSize, byte *&unc
png_read_info(png_ptr, info_ptr);
// PNG Informationen auslesen
- png_get_IHDR(png_ptr, info_ptr, (png_uint_32 *)&width, (png_uint_32 *)&height, &bitDepth, &colorType, &interlaceType, NULL, NULL);
+
+ png_uint_32 w, h;
+ png_get_IHDR(png_ptr, info_ptr, &w, &h, &bitDepth, &colorType, &interlaceType, NULL, NULL);
+ width = w;
+ height = h;
// Pitch des Ausgabebildes berechnen
pitch = GraphicEngine::calcPitch(GraphicEngine::CF_ARGB32, width);
@@ -163,7 +167,9 @@ bool PNGLoader::doDecodeImage(const byte *fileDataPtr, uint fileSize, byte *&unc
// Nachdem die Transformationen registriert wurden, werden die Bilddaten erneut eingelesen
png_read_update_info(png_ptr, info_ptr);
- png_get_IHDR(png_ptr, info_ptr, (png_uint_32 *)&width, (png_uint_32 *)&height, &bitDepth, &colorType, NULL, NULL, NULL);
+ png_get_IHDR(png_ptr, info_ptr, &w, &h, &bitDepth, &colorType, NULL, NULL, NULL);
+ width = w;
+ height = h;
if (interlaceType == PNG_INTERLACE_NONE) {
// PNGs without interlacing can simply be read row by row.
@@ -235,7 +241,11 @@ bool PNGLoader::doImageProperties(const byte *fileDataPtr, uint fileSize, int &w
// PNG Informationen auslesen
int bitDepth;
int colorType;
- png_get_IHDR(png_ptr, info_ptr, (png_uint_32 *)&width, (png_uint_32 *)&height, &bitDepth, &colorType, NULL, NULL, NULL);
+ png_uint_32 w, h;
+ png_get_IHDR(png_ptr, info_ptr, &w, &h, &bitDepth, &colorType, NULL, NULL, NULL);
+
+ width = w;
+ height = h;
// Die Strukturen freigeben
png_destroy_read_struct(&png_ptr, &info_ptr, NULL);