diff options
author | John Wiegley <johnw@newartisans.com> | 2009-02-28 04:36:48 -0400 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2009-02-28 04:36:48 -0400 |
commit | fb129fa7a1b293d3a04513aee3ca4a489f094754 (patch) | |
tree | 11159ed848fc5e556bc47718d2defa98022d972c | |
parent | 56693fab9b98b083308f628284e73ce2797f8a5f (diff) | |
download | fork-ledger-fb129fa7a1b293d3a04513aee3ca4a489f094754.tar.gz fork-ledger-fb129fa7a1b293d3a04513aee3ca4a489f094754.tar.bz2 fork-ledger-fb129fa7a1b293d3a04513aee3ca4a489f094754.zip |
Corrected a potential invalid memory access
-rw-r--r-- | src/amount.cc | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/amount.cc b/src/amount.cc index a6c1eb35..ded85e74 100644 --- a/src/amount.cc +++ b/src/amount.cc @@ -675,10 +675,13 @@ bool amount_t::is_zero() const std::ostringstream out; stream_out_mpq(out, MP(quantity), commodity().precision()); - - for (const char * p = out.str().c_str(); *p; p++) - if (*p != '0' && *p != '.' && *p != '-') - return false; + + string output = out.str(); + if (! output.empty()) { + for (const char * p = output.c_str(); *p; p++) + if (*p != '0' && *p != '.' && *p != '-') + return false; + } return true; } } |