all repos — mgba @ f51044e94c9616868526802a71ffca1ec12a1ca1

mGBA Game Boy Advance Emulator

Util: Attempt to fix erroneous clobber warning
Jeffrey Pfau jeffrey@endrift.com
Sun, 22 Feb 2015 01:32:02 -0800
commit

f51044e94c9616868526802a71ffca1ec12a1ca1

parent

815e4d5b0d1983f47ac18d3a4b4d7d6bde9a0ce2

1 files changed, 6 insertions(+), 6 deletions(-)

jump to
M src/util/png-io.csrc/util/png-io.c

@@ -149,21 +149,21 @@ }

uint8_t* pixelData = pixels; unsigned pngHeight = png_get_image_height(png, info); - if (height > pngHeight) { - height = pngHeight; + if (height < pngHeight) { + pngHeight = height; } unsigned pngWidth = png_get_image_width(png, info); - if (width > pngWidth) { - width = pngWidth; + if (width < pngWidth) { + pngWidth = width; } unsigned i; png_bytep row = malloc(png_get_rowbytes(png, info)); - for (i = 0; i < height; ++i) { + for (i = 0; i < pngHeight; ++i) { png_read_row(png, row, 0); unsigned x; - for (x = 0; x < width; ++x) { + for (x = 0; x < pngWidth; ++x) { pixelData[stride * i * 4 + x * 4] = row[x * 3]; pixelData[stride * i * 4 + x * 4 + 1] = row[x * 3 + 1]; pixelData[stride * i * 4 + x * 4 + 2] = row[x * 3 + 2];