mirror of
https://github.com/libretro/scummvm.git
synced 2025-02-19 10:41:55 +00:00
HDB: Fix memory leaks due to findFirstData()
This commit is contained in:
parent
7b78aa5e9f
commit
fa71ee9034
@ -128,7 +128,7 @@ Common::SeekableReadStream *FileMan::findFirstData(const char *string, DataType
|
||||
|
||||
// Load corresponding file into a buffer
|
||||
_mpcFile->seek(file->offset);
|
||||
byte *buffer = new byte[file->ulength];
|
||||
byte *buffer = (byte *)malloc(file->ulength * sizeof(byte));
|
||||
|
||||
_mpcFile->read(buffer, file->ulength);
|
||||
|
||||
|
@ -386,6 +386,7 @@ Picture *Gfx::loadPic(const char *picName) {
|
||||
if (!stream)
|
||||
return NULL;
|
||||
pic->load(stream);
|
||||
delete stream;
|
||||
return pic;
|
||||
}
|
||||
|
||||
@ -395,6 +396,7 @@ Tile *Gfx::loadTile(const char *tileName) {
|
||||
if (!stream)
|
||||
return NULL;
|
||||
tile->load(stream);
|
||||
delete stream;
|
||||
return tile;
|
||||
}
|
||||
|
||||
@ -404,6 +406,7 @@ Tile *Gfx::loadIcon(const char *tileName) {
|
||||
if (!stream)
|
||||
return NULL;
|
||||
tile->load(stream);
|
||||
delete stream;
|
||||
return tile;
|
||||
}
|
||||
|
||||
@ -424,6 +427,7 @@ Tile *Gfx::getTile(int index) {
|
||||
Common::SeekableReadStream *stream = g_hdb->_fileMan->findFirstData(_tLookupArray[index].filename, TYPE_TILE32);
|
||||
Tile *tile = new Tile;
|
||||
tile->load(stream);
|
||||
delete stream;
|
||||
_tLookupArray[index].tData = tile;
|
||||
}
|
||||
|
||||
@ -455,6 +459,7 @@ Picture *Gfx::getPicture(const char *name) {
|
||||
Common::SeekableReadStream *stream = g_hdb->_fileMan->findFirstData(name, TYPE_PIC);
|
||||
Picture *picture = new Picture;
|
||||
picture->load(stream);
|
||||
delete stream;
|
||||
return picture;
|
||||
}
|
||||
|
||||
@ -523,6 +528,7 @@ Tile *Gfx::getTileGfx(const char *name, int32 size) {
|
||||
|
||||
Tile *gfxTile = new Tile;
|
||||
gfxTile->load(stream);
|
||||
delete stream;
|
||||
|
||||
gc->tileGfx = gfxTile;
|
||||
if (size == -1)
|
||||
@ -562,6 +568,7 @@ Picture *Gfx::getPicGfx(const char *name, int32 size) {
|
||||
|
||||
Picture *gfxPic = new Picture;
|
||||
gfxPic->load(stream);
|
||||
delete stream;
|
||||
|
||||
gc->picGfx = gfxPic;
|
||||
if (size == -1)
|
||||
@ -753,6 +760,7 @@ bool Gfx::loadFont(const char *string) {
|
||||
|
||||
// Loading _fontGfx
|
||||
_fontGfx = stream->readUint16LE();
|
||||
delete stream;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -833,6 +833,7 @@ Common::Error HDBGame::run() {
|
||||
|
||||
Picture *titlePic = new Picture;
|
||||
titlePic->load(titleStream);
|
||||
delete titleStream;
|
||||
|
||||
Common::SeekableReadStream *tileStream = _fileMan->findFirstData("t32_ground1", TYPE_TILE32);
|
||||
if (tileStream == NULL) {
|
||||
@ -842,6 +843,7 @@ Common::Error HDBGame::run() {
|
||||
|
||||
Tile *tile = new Tile;
|
||||
tile->load(tileStream);
|
||||
delete tileStream;
|
||||
#endif
|
||||
|
||||
if (ConfMan.hasKey("boot_param")) {
|
||||
|
@ -66,6 +66,8 @@ LuaScript::~LuaScript() {
|
||||
if (_state) {
|
||||
lua_close(_state);
|
||||
}
|
||||
if (_globalLuaStream)
|
||||
delete _globalLuaStream;
|
||||
}
|
||||
|
||||
bool LuaScript::init() {
|
||||
@ -92,6 +94,7 @@ bool LuaScript::loadLua(const char *name) {
|
||||
}
|
||||
|
||||
_systemInit = initScript(luaStream, name, luaLength);
|
||||
delete luaStream;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -264,6 +264,7 @@ bool Map::loadMap(char *name) {
|
||||
}
|
||||
|
||||
load(mapStream);
|
||||
delete mapStream;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user