From fb129fa7a1b293d3a04513aee3ca4a489f094754 Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Sat, 28 Feb 2009 04:36:48 -0400 Subject: Corrected a potential invalid memory access --- src/amount.cc | 11 +++++++---- 1 file 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; } } -- cgit v1.2.3