From c32e372dd481d4d14e061d55a41758299719385b Mon Sep 17 00:00:00 2001 From: Thomas Goyne Date: Fri, 15 Jul 2011 17:36:53 +0000 Subject: [PATCH] Fix leak of the Options object in agi::Path and potential overwriting of the config file with an out of date version on shutdown Originally committed to SVN as r5477. --- aegisub/libaegisub/common/path.cpp | 12 ++++++------ aegisub/libaegisub/include/libaegisub/path.h | 3 ++- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/aegisub/libaegisub/common/path.cpp b/aegisub/libaegisub/common/path.cpp index a52582651..879cd8104 100644 --- a/aegisub/libaegisub/common/path.cpp +++ b/aegisub/libaegisub/common/path.cpp @@ -22,24 +22,25 @@ #include #endif +#include "libaegisub/path.h" + #include "libaegisub/access.h" #include "libaegisub/log.h" -#include "libaegisub/path.h" #include "libaegisub/option.h" #include "libaegisub/option_value.h" namespace agi { Path::Path(const std::string &file, const std::string& default_path) -: path_file(file), -path_default(default_path) { - opt = new agi::Options(file, default_path); +: path_file(file) +, path_default(default_path) +, opt(new agi::Options(file, default_path, Options::FLUSH_SKIP)) +{ opt->ConfigUser(); LOG_D("agi/path") << "New Path object"; } Path::~Path() { - opt->Flush(); } @@ -71,7 +72,6 @@ void Path::Set(const char *name, const std::string &path) { } catch (OptionErrorNotFound&) { throw PathErrorNotFound("Invalid path key"); } - } diff --git a/aegisub/libaegisub/include/libaegisub/path.h b/aegisub/libaegisub/include/libaegisub/path.h index bcc932f18..6b1462ed2 100644 --- a/aegisub/libaegisub/include/libaegisub/path.h +++ b/aegisub/libaegisub/include/libaegisub/path.h @@ -22,6 +22,7 @@ #endif #include +#include namespace agi { @@ -97,7 +98,7 @@ private: void Encode(std::string &path); /// Options object. - Options *opt; + scoped_ptr opt; /// @brief Locale files /// @return Locale location