Misc cleanups; memory leaks, use-after-free, use of uninitialized data

There are still a bunch of tiny leaks related to the animation Tween data that
I haven't figured out how to resolve, but it runs more cleanly now.
This commit is contained in:
Levi Pearson 2017-01-28 22:32:17 -07:00
parent aacb41102f
commit 0ce28a46a2
4 changed files with 13 additions and 3 deletions

View File

@ -85,7 +85,7 @@ void Configuration::initialize()
if(rootPos!=std::string::npos)
sPath = sPath.erase(rootPos);
#else
char exepath[1024];
char exepath[1024] = {};
sprintf(exepath, "/proc/%d/exe", getpid());
readlink(exepath, exepath, sizeof(exepath));
std::string sPath(exepath);

View File

@ -327,12 +327,14 @@ void MetadataDatabase::injectMetadata(CollectionInfo *collection)
}
rc = sqlite3_step(stmt);
}
sqlite3_finalize(stmt);
}
bool MetadataDatabase::needsRefresh()
{
sqlite3 *handle = db_.handle;
sqlite3_stmt *stmt;
bool result;
sqlite3_prepare_v2(handle,
"SELECT COUNT(*) FROM Meta;",
@ -357,12 +359,16 @@ bool MetadataDatabase::needsRefresh()
#endif
time_t metadirTime = timeDir(Utils::combinePath(Configuration::absolutePath, "meta"));
return (count == 0 || metadbErr || metadb.st_mtime < metadirTime || exeErr || metadb.st_mtime < exe.st_mtime) ? true : false;
result = (count == 0 || metadbErr || metadb.st_mtime < metadirTime || exeErr || metadb.st_mtime < exe.st_mtime) ? true : false;
}
else
{
return true;
result = true;
}
sqlite3_finalize(stmt);
return result;
}
bool MetadataDatabase::importHyperlist(std::string hyperlistFile, std::string collectionName)

View File

@ -523,7 +523,10 @@ bool Page::popCollection()
playlist_ = info->playlist;
playlistChange();
// Remove references to the collection we're about to delete and pop the menu
menuDepth_--;
activeMenu_->collectionName = "";
activeMenu_->setItems(NULL);
activeMenu_ = menus_[menuDepth_ - 1];
for(std::vector<Component *>::iterator it = LayerComponents.begin(); it != LayerComponents.end(); ++it)

View File

@ -914,6 +914,7 @@ CollectionInfo *RetroFE::getCollection(std::string collectionName)
}
}
}
closedir(dp);
bool menuSort = true;
config_.getProperty("collections." + collectionName + ".list.menuSort", menuSort);