From b80a9d4f533bdd0517c0435230e20f57d8975e2e Mon Sep 17 00:00:00 2001 From: WrinklyNinja Date: Thu, 24 Oct 2013 22:56:06 +0100 Subject: [PATCH] Fixed some crashing. --- src/backend/game.cpp | 20 +++++++++----------- src/backend/metadata.cpp | 4 ++-- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/src/backend/game.cpp b/src/backend/game.cpp index 81efa54f..352d788a 100644 --- a/src/backend/game.cpp +++ b/src/backend/game.cpp @@ -302,7 +302,7 @@ namespace boss { ret = lo_create_handle(&gh, LIBLO_GAME_FNV, gamePath.string().c_str()); if (ret != LIBLO_OK && ret != LIBLO_WARN_LO_MISMATCH) { - const char * e; + const char * e = NULL; lo_get_error_message(&e); BOOST_LOG_TRIVIAL(error) << "libloadorder failed to create a game handle. Details: " << e; string err = lc::translate("libloadorder failed to create a game handle. Details:").str() + " " + e; @@ -313,7 +313,7 @@ namespace boss { ret = lo_set_game_master(gh, _masterFile.c_str()); if (ret != LIBLO_OK) { - const char * e; + const char * e = NULL; lo_get_error_message(&e); lo_destroy_handle(gh); BOOST_LOG_TRIVIAL(error) << "libloadorder failed to initialise game master file support. Details: " << e; @@ -323,7 +323,7 @@ namespace boss { } if (lo_get_load_order(gh, &pluginArr, &pluginArrSize) != LIBLO_OK) { - const char * e; + const char * e = NULL; lo_get_error_message(&e); lo_destroy_handle(gh); BOOST_LOG_TRIVIAL(error) << "libloadorder failed to set the load order. Details: " << e; @@ -343,10 +343,9 @@ namespace boss { void Game::SetLoadOrder(const std::list& loadOrder) const { BOOST_LOG_TRIVIAL(trace) << "Setting load order for game: " << _name; - lo_game_handle gh; - char ** pluginArr; - size_t pluginArrSize; - + lo_game_handle gh = NULL; + char ** pluginArr = NULL; + size_t pluginArrSize = 0; int ret; if (Id() == g_game_tes4) ret = lo_create_handle(&gh, LIBLO_GAME_TES4, gamePath.string().c_str()); @@ -358,7 +357,7 @@ namespace boss { ret = lo_create_handle(&gh, LIBLO_GAME_FNV, gamePath.string().c_str()); if (ret != LIBLO_OK && ret != LIBLO_WARN_LO_MISMATCH) { - const char * e; + const char * e = NULL; lo_get_error_message(&e); BOOST_LOG_TRIVIAL(error) << "libloadorder failed to create a game handle. Details: " << e; string err = lc::translate("libloadorder failed to create a game handle. Details:").str() + " " + e; @@ -367,9 +366,8 @@ namespace boss { } ret = lo_set_game_master(gh, _masterFile.c_str()); - if (ret != LIBLO_OK) { - const char * e; + const char * e = NULL; lo_get_error_message(&e); lo_destroy_handle(gh); BOOST_LOG_TRIVIAL(error) << "libloadorder failed to initialise game master file support. Details: " << e; @@ -391,7 +389,7 @@ namespace boss { for (size_t i=0; i < pluginArrSize; i++) delete [] pluginArr[i]; delete [] pluginArr; - const char * e; + const char * e = NULL; lo_get_error_message(&e); lo_destroy_handle(gh); BOOST_LOG_TRIVIAL(error) << "libloadorder failed to set the load order. Details: " << e; diff --git a/src/backend/metadata.cpp b/src/backend/metadata.cpp index b82974cc..2f3ed0ee 100644 --- a/src/backend/metadata.cpp +++ b/src/backend/metadata.cpp @@ -401,7 +401,7 @@ namespace boss { } void Plugin::Merge(const Plugin& plugin, bool ifDisabled) { - BOOST_LOG_TRIVIAL(trace) << "Merging plugin metadata."; + BOOST_LOG_TRIVIAL(trace) << "Merging metadata for: " << name; //If 'name' differs or if 'enabled' is false for the given plugin, don't change anything. if ((!plugin.Enabled() && !ifDisabled)) return; @@ -441,7 +441,7 @@ namespace boss { } Plugin Plugin::DiffMetadata(const Plugin& plugin) const { - BOOST_LOG_TRIVIAL(trace) << "Calculating metadata difference between plugins."; + BOOST_LOG_TRIVIAL(trace) << "Calculating metadata difference for: " << name; Plugin p(*this); //Compare this plugin against the given plugin.