From 60f898af671280bfd4f098c69bf02a5f78ab292f Mon Sep 17 00:00:00 2001 From: Alex Szpakowski Date: Sat, 1 Apr 2017 21:20:08 -0300 Subject: [PATCH] Fix a crash when loading .pvr compressed texture. --HG-- branch : minor --- src/modules/image/magpie/EXRHandler.cpp | 2 +- src/modules/image/magpie/PVRHandler.cpp | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/modules/image/magpie/EXRHandler.cpp b/src/modules/image/magpie/EXRHandler.cpp index cd9b64ebc..77260a78a 100644 --- a/src/modules/image/magpie/EXRHandler.cpp +++ b/src/modules/image/magpie/EXRHandler.cpp @@ -101,7 +101,7 @@ static T *loadEXRChannels(int width, int height, T *rgba[4], T one) FormatHandler::DecodedImage EXRHandler::decode(love::filesystem::FileData *data) { - const char *err; + const char *err = "unknown error"; auto mem = (const unsigned char *) data->getData(); size_t memsize = data->getSize(); DecodedImage img; diff --git a/src/modules/image/magpie/PVRHandler.cpp b/src/modules/image/magpie/PVRHandler.cpp index 387477fc1..ca1d74359 100644 --- a/src/modules/image/magpie/PVRHandler.cpp +++ b/src/modules/image/magpie/PVRHandler.cpp @@ -513,7 +513,6 @@ StrongRef PVRHandler::parse(filesystem::FileData *f throw love::Exception("Could not parse PVR file: unsupported image format."); size_t totalsize = 0; - uint8 *data = nullptr; // Ignore faces and surfaces except the first ones (for now.) for (int i = 0; i < (int) header3.numMipmaps; i++) @@ -541,7 +540,7 @@ StrongRef PVRHandler::parse(filesystem::FileData *f int width = std::max((int) header3.width >> i, 1); int height = std::max((int) header3.height >> i, 1); - memcpy(data + curoffset, filebytes + curoffset, mipsize); + memcpy(memory->data + curoffset, filebytes + curoffset, mipsize); auto slice = new CompressedImageData::Slice(cformat, width, height, memory, curoffset, mipsize); images.push_back(slice);