(convert_number): If the denominator is zero, report an error instead
of crashing.
This commit is contained in:
parent
d6475fc4a2
commit
8ca6c6b827
1 changed files with 6 additions and 1 deletions
|
|
@ -145,7 +145,12 @@ static amount_t convert_number(const std::string& number)
|
||||||
amount_t amt(numer_str);
|
amount_t amt(numer_str);
|
||||||
amount_t den(denom_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 {
|
} else {
|
||||||
return amount_t(number);
|
return amount_t(number);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue