Permalink
Browse files

Fix a couple of memory leaks in mythgame. Coverity defects 703765 & 7…

…03766
  • Loading branch information...
stuartm committed Jun 4, 2012
1 parent faf6dbc commit 7809398b32a24a7c0ab876b5726370f0c6b0626e
Showing with 9 additions and 9 deletions.
  1. +5 −5 mythplugins/mythgame/mythgame/gamescan.cpp
  2. +4 −4 mythplugins/mythgame/mythgame/rominfo.cpp
@@ -114,11 +114,11 @@ void GameScannerThread::updateDB()
{
if (!(*p).indb)
{
- RomInfo *add = new RomInfo(0, (*p).romfile, (*p).system,
- (*p).romname, "", "", "", (*p).rompath,
- "", "", 0, (*p).gametype, 0, "", "", "",
- "", "", "", "", "");
- add->SaveToDatabase();
+ RomInfo add(0, (*p).romfile, (*p).system,
+ (*p).romname, "", "", "", (*p).rompath,
+ "", "", 0, (*p).gametype, 0, "", "", "",
+ "", "", "", "", "");
+ add.SaveToDatabase();
m_DBDataChanged = true;
}
if (m_HasGUI)
@@ -369,7 +369,7 @@ QList<RomInfo*> RomInfo::GetAllRomInfo()
RomInfo *RomInfo::GetRomInfoById(int id)
{
- RomInfo *ret = new RomInfo();
+ RomInfo *ret = NULL;
MSqlQuery query(MSqlQuery::InitCon());
@@ -382,10 +382,7 @@ RomInfo *RomInfo::GetRomInfoById(int id)
query.bindValue(":INTID", id);
if (!query.exec())
- {
MythDB::DBError("GetRomInfoById", query);
- return ret;
- }
if (query.next())
{
@@ -412,6 +409,9 @@ RomInfo *RomInfo::GetRomInfoById(int id)
query.value(17).toString());
}
+ if (!ret)
+ ret = new RomInfo();
+
return ret;
}

0 comments on commit 7809398

Please sign in to comment.