diff --git a/src/modules/filesystem/FileData.cpp b/src/modules/filesystem/FileData.cpp index 35ceefda9..4e0f3972d 100644 --- a/src/modules/filesystem/FileData.cpp +++ b/src/modules/filesystem/FileData.cpp @@ -78,7 +78,7 @@ bool FileData::getConstant(const char *in, Decoder &out) return decoders.find(in, out); } -bool FileData::getConstant(Decoder in, const char *&out) +bool FileData::getConstant(Decoder in, const char *&out) { return decoders.find(in, out); } diff --git a/src/modules/filesystem/FileData.h b/src/modules/filesystem/FileData.h index d2909dd48..7106cdb7d 100644 --- a/src/modules/filesystem/FileData.h +++ b/src/modules/filesystem/FileData.h @@ -55,7 +55,7 @@ public: const std::string &getExtension() const; static bool getConstant(const char *in, Decoder &out); - static bool getConstant(Decoder in, const char *&out); + static bool getConstant(Decoder in, const char *&out); private: diff --git a/src/modules/image/magpie/ImageData.cpp b/src/modules/image/magpie/ImageData.cpp index 79fa26511..b4af00adf 100644 --- a/src/modules/image/magpie/ImageData.cpp +++ b/src/modules/image/magpie/ImageData.cpp @@ -124,10 +124,7 @@ void ImageData::decode(love::filesystem::FileData *data) // The decoder *must* output a 32 bits-per-pixel image. if (decodedimage.size != decodedimage.width*decodedimage.height*sizeof(pixel)) { - if (decodeHandler) - decodeHandler->free(decodedimage.data); - else - delete[] decodedimage.data; + decoder->free(decodedimage.data); throw love::Exception("Could not convert image!"); } diff --git a/src/modules/image/magpie/STBHandler.cpp b/src/modules/image/magpie/STBHandler.cpp index ac4ed76b4..72ea4aa78 100644 --- a/src/modules/image/magpie/STBHandler.cpp +++ b/src/modules/image/magpie/STBHandler.cpp @@ -75,7 +75,12 @@ FormatHandler::DecodedImage STBHandler::decode(love::filesystem::FileData *data) &comp, 4); if (img.data == nullptr || img.width <= 0 || img.height <= 0) - throw love::Exception("Could not decode image with stb_image."); + { + const char *err = stbi_failure_reason(); + if (err == nullptr) + err = "unknown error"; + throw love::Exception("Could not decode image with stb_image (%s).", err); + } img.size = img.width * img.height * 4;