mirror of
https://github.com/love2d/love.git
synced 2026-08-19 20:19:42 +02:00
Fix a crash when loading .pvr compressed texture.
--HG-- branch : minor
This commit is contained in:
@@ -101,7 +101,7 @@ static T *loadEXRChannels(int width, int height, T *rgba[4], T one)
|
|||||||
|
|
||||||
FormatHandler::DecodedImage EXRHandler::decode(love::filesystem::FileData *data)
|
FormatHandler::DecodedImage EXRHandler::decode(love::filesystem::FileData *data)
|
||||||
{
|
{
|
||||||
const char *err;
|
const char *err = "unknown error";
|
||||||
auto mem = (const unsigned char *) data->getData();
|
auto mem = (const unsigned char *) data->getData();
|
||||||
size_t memsize = data->getSize();
|
size_t memsize = data->getSize();
|
||||||
DecodedImage img;
|
DecodedImage img;
|
||||||
|
|||||||
@@ -513,7 +513,6 @@ StrongRef<CompressedImageData::Memory> PVRHandler::parse(filesystem::FileData *f
|
|||||||
throw love::Exception("Could not parse PVR file: unsupported image format.");
|
throw love::Exception("Could not parse PVR file: unsupported image format.");
|
||||||
|
|
||||||
size_t totalsize = 0;
|
size_t totalsize = 0;
|
||||||
uint8 *data = nullptr;
|
|
||||||
|
|
||||||
// Ignore faces and surfaces except the first ones (for now.)
|
// Ignore faces and surfaces except the first ones (for now.)
|
||||||
for (int i = 0; i < (int) header3.numMipmaps; i++)
|
for (int i = 0; i < (int) header3.numMipmaps; i++)
|
||||||
@@ -541,7 +540,7 @@ StrongRef<CompressedImageData::Memory> PVRHandler::parse(filesystem::FileData *f
|
|||||||
int width = std::max((int) header3.width >> i, 1);
|
int width = std::max((int) header3.width >> i, 1);
|
||||||
int height = std::max((int) header3.height >> 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);
|
auto slice = new CompressedImageData::Slice(cformat, width, height, memory, curoffset, mipsize);
|
||||||
images.push_back(slice);
|
images.push_back(slice);
|
||||||
|
|||||||
Reference in New Issue
Block a user