Fixed filedata not being cleaned up when love.image.newImageData(filepath) fails

This commit is contained in:
Alex Szpakowski
2013-03-19 09:01:15 -03:00
parent f3290d84b7
commit 9e9eb42f1d
3 changed files with 11 additions and 10 deletions
+11 -3
View File
@@ -53,7 +53,15 @@ ImageData::ImageData(Data *data)
ImageData::ImageData(filesystem::File *file)
{
Data *data = file->read();
load(data);
try
{
load(data);
}
catch (love::Exception &)
{
data->release();
throw;
}
data->release();
}
@@ -124,10 +132,10 @@ void ImageData::load(Data *data)
create(width, height, ilGetData());
}
catch(std::exception &)
catch(std::exception &e)
{
ilDeleteImages(1, &image);
throw;
throw love::Exception("%s", e.what());
}
ilDeleteImages(1, &image);