From a143d4ce58d1103b37fa297fe6f4f4878eea59ca Mon Sep 17 00:00:00 2001 From: "Wladimir J. van der Laan" Date: Mon, 17 Feb 2014 11:32:43 +0100 Subject: Fix crash in importwallet and dumpwallet formatting - DecodeDumpTime was passing a statically allocated facet object to std::locale. However, "The constructed locale object takes over responsibility for deleting this facet object." causing a free() crash on scope exit. Fixes #3670. - EncodeDumpTime was using the wrong format character for dates (appears accidentally introduced in 51ed9ec9) --- src/rpcdump.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/rpcdump.cpp') diff --git a/src/rpcdump.cpp b/src/rpcdump.cpp index a912ea7670..9e1d47846e 100644 --- a/src/rpcdump.cpp +++ b/src/rpcdump.cpp @@ -23,13 +23,13 @@ using namespace std; void EnsureWalletIsUnlocked(); std::string static EncodeDumpTime(int64_t nTime) { - return DateTimeStrFormat("%Y-%m-%"PRId64"T%H:%M:%SZ", nTime); + return DateTimeStrFormat("%Y-%m-%dT%H:%M:%SZ", nTime); } int64_t static DecodeDumpTime(const std::string &str) { - static boost::posix_time::time_input_facet facet("%Y-%m-%dT%H:%M:%SZ"); static const boost::posix_time::ptime epoch = boost::posix_time::from_time_t(0); - const std::locale loc(std::locale::classic(), &facet); + static const std::locale loc(std::locale::classic(), + new boost::posix_time::time_input_facet("%Y-%m-%dT%H:%M:%SZ")); std::istringstream iss(str); iss.imbue(loc); boost::posix_time::ptime ptime(boost::date_time::not_a_date_time); -- cgit v1.2.3