From 635fae15dabcb0ef00cf4bb40300249a5e101cd7 Mon Sep 17 00:00:00 2001 From: IntelOrca Date: Wed, 30 Dec 2015 13:54:17 +0000 Subject: [PATCH] move assertion outside of loop, rowBytes does not change --- src/image_io.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/image_io.c b/src/image_io.c index cc14cc012c..4ff6d93f1a 100644 --- a/src/image_io.c +++ b/src/image_io.c @@ -63,10 +63,8 @@ bool image_io_png_read(uint8 **pixels, uint32 *width, uint32 *height, const utf8 uint8 *dst = pngPixels; if (color_type == PNG_COLOR_TYPE_RGB) { // 24-bit PNG (no alpha) - const png_size_t expectedRowSize = pngWidth * 3; + assert(rowBytes == pngWidth * 3); for (png_uint_32 i = 0; i < pngHeight; i++) { - assert(rowBytes == expectedRowSize); - uint8 *src = rowPointers[i]; for (png_uint_32 x = 0; x < pngWidth; x++) { *dst++ = *src++; @@ -77,10 +75,8 @@ bool image_io_png_read(uint8 **pixels, uint32 *width, uint32 *height, const utf8 } } else { // 32-bit PNG (with alpha) - const png_size_t expectedRowSize = pngWidth * 4; + assert(rowBytes == pngWidth * 4); for (png_uint_32 i = 0; i < pngHeight; i++) { - assert(rowBytes == expectedRowSize); - memcpy(dst, rowPointers[i], rowBytes); dst += rowBytes; }