summaryrefslogtreecommitdiff
path: root/src/times.cc
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2010-06-02 00:19:07 -0400
committerJohn Wiegley <johnw@newartisans.com>2010-06-02 00:27:35 -0400
commite0c5f6db30382960fa60739c368e3700e5f71b67 (patch)
treed1bef21c1c6e272c13c6d50d85bedc4c64adc34a /src/times.cc
parent281225db1380d7ab3a741820c27c0e20beddc977 (diff)
downloadfork-ledger-e0c5f6db30382960fa60739c368e3700e5f71b67.tar.gz
fork-ledger-e0c5f6db30382960fa60739c368e3700e5f71b67.tar.bz2
fork-ledger-e0c5f6db30382960fa60739c368e3700e5f71b67.zip
Fixed two memory reference errors
Diffstat (limited to 'src/times.cc')
-rw-r--r--src/times.cc13
1 files changed, 6 insertions, 7 deletions
diff --git a/src/times.cc b/src/times.cc
index 35082f51..a7906aee 100644
--- a/src/times.cc
+++ b/src/times.cc
@@ -197,8 +197,6 @@ namespace {
optional_year year,
date_traits_t * traits = NULL)
{
- date_t when;
-
VERIFY(std::strlen(date_str) < 127);
char buf[128];
@@ -208,7 +206,7 @@ namespace {
if (*p == '.' || *p == '-')
*p = '/';
- when = io.parse(buf);
+ date_t when = io.parse(buf);
if (! when.is_not_a_date()) {
DEBUG("times.parse", "Passed date string: " << date_str);
@@ -216,12 +214,13 @@ namespace {
DEBUG("times.parse", "Parsed result is: " << when);
DEBUG("times.parse", "Formatted result is: " << io.format(when));
- const char * p = io.format(when).c_str();
+ string when_str = io.format(when);
+
+ const char * p = when_str.c_str();
const char * q = buf;
- for (; *p != '\0' && *q != '\0';
- p++, q++) {
+ for (; *p && *q; p++, q++) {
if (*p != *q && *p == '0') p++;
- if (*p != *q) break;
+ if (! *p || *p != *q) break;
}
if (*p != '\0' || *q != '\0')
throw_(date_error, _("Invalid date: %1") << date_str);