summaryrefslogtreecommitdiff
path: root/Source/Core/Common/Image.cpp
diff options
context:
space:
mode:
authorJosJuice <josjuice@gmail.com>2018-04-11 16:11:38 +0200
committerJosJuice <josjuice@gmail.com>2018-05-20 13:44:42 +0200
commit10ff6d73c20b968b33ed669b2ce4f447c668cde8 (patch)
tree808df4a85d3193c74e428fef21572855eb3ebf43 /Source/Core/Common/Image.cpp
parentc51ae9c62aa471a2b91fbdf548e0ab3591b2d717 (diff)
Fix compatibility with versions of libpng older than 1.5
Diffstat (limited to 'Source/Core/Common/Image.cpp')
-rw-r--r--Source/Core/Common/Image.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/Source/Core/Common/Image.cpp b/Source/Core/Common/Image.cpp
index 2ce3fbfabf..fdbc246efb 100644
--- a/Source/Core/Common/Image.cpp
+++ b/Source/Core/Common/Image.cpp
@@ -4,11 +4,14 @@
#include "Common/Image.h"
+// Versions of libpng older than 1.5 want us to not include setjmp.h before png.h,
+// so let's include png.h first of all headers
+#include <png.h>
+
#include <csetjmp>
#include <cstdlib>
#include <cstring>
#include <memory>
-#include <png.h>
#include <vector>
#include "Common/CommonTypes.h"
@@ -87,7 +90,8 @@ static void PNGErrorCallback(png_structp png, png_const_charp error_msg)
bool LoadPNG(const std::vector<u8>& input, std::vector<u8>* data_out, u32* width_out,
u32* height_out)
{
- const bool is_png = !png_sig_cmp(input.data(), 0, input.size());
+ // The const_cast is only required for libpng versions older than 1.5
+ const bool is_png = !png_sig_cmp(const_cast<u8*>(input.data()), 0, input.size());
if (!is_png)
return false;