Fix possible segfault when a DecodeHandler fails to decode an image properly

This commit is contained in:
Bart van Strien
2015-06-23 13:35:32 +02:00
parent bf1b409da1
commit e3ff0a0d63
+4 -1
View File
@@ -124,7 +124,10 @@ 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))
{
delete[] decodedimage.data;
if (decodeHandler)
decodeHandler->free(decodedimage.data);
else
delete[] decodedimage.data;
throw love::Exception("Could not convert image!");
}