summaryrefslogtreecommitdiff
path: root/src/times.cc
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2012-05-14 21:37:13 -0600
committerJohn Wiegley <johnw@newartisans.com>2012-05-14 21:41:38 -0600
commit32eaa0346959188a030cd217ec02b02040efeb26 (patch)
tree17dcb448dfbbbb76ed8b367aac53d9e00973a8f3 /src/times.cc
parentb898d40a81167113b7c235b9458636b29f90fd86 (diff)
downloadfork-ledger-32eaa0346959188a030cd217ec02b02040efeb26.tar.gz
fork-ledger-32eaa0346959188a030cd217ec02b02040efeb26.tar.bz2
fork-ledger-32eaa0346959188a030cd217ec02b02040efeb26.zip
Fixed a hidden memory corruption bug
Diffstat (limited to 'src/times.cc')
-rw-r--r--src/times.cc8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/times.cc b/src/times.cc
index 3c556a47..30da301f 100644
--- a/src/times.cc
+++ b/src/times.cc
@@ -48,7 +48,7 @@ namespace {
template <typename T, typename InputFacetType, typename OutputFacetType>
class temporal_io_t : public noncopyable
{
- const char * fmt_str;
+ string fmt_str;
#if defined(USE_BOOST_FACETS)
std::istringstream input_stream;
std::ostringstream output_stream;
@@ -104,7 +104,7 @@ namespace {
#else // USE_BOOST_FACETS
std::tm data(to_tm(when));
char buf[128];
- std::strftime(buf, 127, fmt_str, &data);
+ std::strftime(buf, 127, fmt_str.c_str(), &data);
return buf;
#endif // USE_BOOST_FACETS
}
@@ -138,7 +138,7 @@ namespace {
#else // USE_BOOST_FACETS
std::tm data;
std::memset(&data, 0, sizeof(std::tm));
- if (strptime(str, fmt_str, &data))
+ if (strptime(str, fmt_str.c_str(), &data))
return posix_time::ptime_from_tm(data);
else
return datetime_t();
@@ -175,7 +175,7 @@ namespace {
std::memset(&data, 0, sizeof(std::tm));
data.tm_year = CURRENT_DATE().year() - 1900;
data.tm_mday = 1; // some formats have no day
- if (strptime(str, fmt_str, &data))
+ if (strptime(str, fmt_str.c_str(), &data))
return gregorian::date_from_tm(data);
else
return date_t();