mirror of
https://github.com/libretro/scummvm.git
synced 2025-01-10 11:51:52 +00:00
EMI: Fix memleaks caused by specialtyTextures
- delete screenshot after texture is created - free _data[] entries in BitmapData::freeData() - destroy _specialtyTextures[] entries in graphic driver's destructors
This commit is contained in:
parent
026166ecf6
commit
ad2ce4a87e
@ -233,6 +233,9 @@ BitmapData::~BitmapData() {
|
||||
|
||||
void BitmapData::freeData() {
|
||||
if (!_keepData) {
|
||||
for (int i = 0; i < _numImages; ++i) {
|
||||
_data[i].free();
|
||||
}
|
||||
delete[] _data;
|
||||
_data = nullptr;
|
||||
}
|
||||
|
@ -480,7 +480,6 @@ void Lua_V2::ThumbnailFromFile() {
|
||||
const char *filename = lua_getstring(filenameObj);
|
||||
|
||||
int width = 256, height = 128;
|
||||
Bitmap *screenshot;
|
||||
|
||||
SaveGame *savedState = SaveGame::openForLoading(filename);
|
||||
if (!savedState || !savedState->isCompatible()) {
|
||||
@ -501,10 +500,11 @@ void Lua_V2::ThumbnailFromFile() {
|
||||
data[l] = savedState->readLEUint16();
|
||||
}
|
||||
Graphics::PixelBuffer buf(Graphics::createPixelFormat<565>(), (byte *)data);
|
||||
screenshot = new Bitmap(buf, width, height, "screenshot");
|
||||
Bitmap *screenshot = new Bitmap(buf, width, height, "screenshot");
|
||||
if (!screenshot) {
|
||||
lua_pushnil();
|
||||
warning("Lua_V2::ThumbnailFromFile: Could not restore screenshot from file %s", filename);
|
||||
delete screenshot;
|
||||
delete[] data;
|
||||
delete savedState;
|
||||
return;
|
||||
@ -512,6 +512,7 @@ void Lua_V2::ThumbnailFromFile() {
|
||||
|
||||
screenshot->_data->convertToColorFormat(Graphics::PixelFormat(4, 8, 8, 8, 8, 0, 8, 16, 24));
|
||||
g_driver->createSpecialtyTexture(index, screenshot->getData(0).getRawBuffer(), width, height);
|
||||
delete screenshot;
|
||||
delete[] data;
|
||||
savedState->endSection();
|
||||
delete savedState;
|
||||
|
@ -124,6 +124,9 @@ GfxOpenGL::~GfxOpenGL() {
|
||||
if (_useDimShader)
|
||||
glDeleteProgramsARB(1, &_dimFragProgram);
|
||||
#endif
|
||||
for (unsigned int i = 0; i < _numSpecialtyTextures; i++) {
|
||||
destroyTexture(&_specialtyTextures[i]);
|
||||
}
|
||||
}
|
||||
|
||||
byte *GfxOpenGL::setupScreen(int screenW, int screenH, bool fullscreen) {
|
||||
|
@ -239,6 +239,9 @@ GfxOpenGLS::GfxOpenGLS() {
|
||||
}
|
||||
|
||||
GfxOpenGLS::~GfxOpenGLS() {
|
||||
for (unsigned int i = 0; i < _numSpecialtyTextures; i++) {
|
||||
destroyTexture(&_specialtyTextures[i]);
|
||||
}
|
||||
delete[] _lights;
|
||||
|
||||
delete _backgroundProgram;
|
||||
|
@ -64,6 +64,9 @@ GfxTinyGL::GfxTinyGL() :
|
||||
}
|
||||
|
||||
GfxTinyGL::~GfxTinyGL() {
|
||||
for (unsigned int i = 0; i < _numSpecialtyTextures; i++) {
|
||||
destroyTexture(&_specialtyTextures[i]);
|
||||
}
|
||||
if (_zb) {
|
||||
delBuffer(1);
|
||||
TinyGL::glClose();
|
||||
|
Loading…
Reference in New Issue
Block a user