(convert_number): If the denominator is zero, report an error instead

of crashing.
This commit is contained in:
John Wiegley 2005-02-01 02:38:17 +00:00
parent d6475fc4a2
commit 8ca6c6b827

View file

@ -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);
}