dfinity / exchange-rate-canister

The exchange rate canister (XRC) makes use of the HTTP requests feature to provide exchange rates as a service to the IC.
Apache License 2.0
37 stars 10 forks source link

`bugfix`: Check the division when inverting the rate to avoid division by zero errors. #186

Closed dfinity-ryancroote closed 1 year ago

dfinity-ryancroote commented 1 year ago

This PR resolves the discovered possibility of division by zero errors while inverting a rate. This is accomplished by updating the division in utils::invert_rate (renamed to utils::checked_invert_rate) to checked_div and returning the result.