From 9e113d88c7128512b3a28459930b4c46bf67b02b Mon Sep 17 00:00:00 2001 From: Maarten ter Huurne Date: Sun, 18 May 2014 21:19:03 +0200 Subject: [PATCH] Fixed compilation with GCC 4.9 --- src/imageio.cpp | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/imageio.cpp b/src/imageio.cpp index 8dbed46..822b0b2 100644 --- a/src/imageio.cpp +++ b/src/imageio.cpp @@ -144,15 +144,19 @@ SDL_Surface *loadPNG(const std::string &path) { goto cleanup; } - // Compute row pointers. - png_bytep rowPointers[height]; - for (png_uint_32 y = 0; y < height; y++) { - rowPointers[y] = - static_cast(surface->pixels) + y * surface->pitch; - } + // Note: GCC 4.9 doesn't want to jump over 'rowPointers' with goto + // if it is in the outer scope. + { + // Compute row pointers. + png_bytep rowPointers[height]; + for (png_uint_32 y = 0; y < height; y++) { + rowPointers[y] = + static_cast(surface->pixels) + y * surface->pitch; + } - // Read the entire image in one go. - png_read_image(png, rowPointers); + // Read the entire image in one go. + png_read_image(png, rowPointers); + } // Read rest of file, and get additional chunks in the info struct. // Note: We got all we need, so skip this step.