summaryrefslogtreecommitdiff
path: root/gnucash.cc
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2005-02-01 02:38:17 +0000
committerJohn Wiegley <johnw@newartisans.com>2008-04-13 02:40:52 -0400
commit8ca6c6b8274585d641510b3f0a537fc66dbd47f4 (patch)
tree47b131e524ad104ba775fcb924ddd89f79d446c8 /gnucash.cc
parentd6475fc4a26826c55f613549588022d3c4803efa (diff)
downloadfork-ledger-8ca6c6b8274585d641510b3f0a537fc66dbd47f4.tar.gz
fork-ledger-8ca6c6b8274585d641510b3f0a537fc66dbd47f4.tar.bz2
fork-ledger-8ca6c6b8274585d641510b3f0a537fc66dbd47f4.zip
(convert_number): If the denominator is zero, report an error instead
of crashing.
Diffstat (limited to 'gnucash.cc')
-rw-r--r--gnucash.cc7
1 files changed, 6 insertions, 1 deletions
diff --git a/gnucash.cc b/gnucash.cc
index e6ef86d0..7912bec2 100644
--- a/gnucash.cc
+++ b/gnucash.cc
@@ -145,7 +145,12 @@ static amount_t convert_number(const std::string& number)
amount_t amt(numer_str);
amount_t den(denom_str);
- return amt / den;
+ if (! den) {
+ have_error = "Denominator in entry is zero!";
+ return amt;
+ } else {
+ return amt / den;
+ }
} else {
return amount_t(number);
}