Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix crash bug by ensuring getTypeByName does not return null #692

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Raystonn
Copy link

If an unknown coin type is read from user data, it will cause getTypeByName to return null. The currentCurrencyMap will then have an asset with key equal to null, which should never happen. That will later cause a crash in CurrencySwitcher.setCurrency. This fix here is to use the BTC coin type as the default instead of returning null.

If an unknown coin type is read from user data, it will cause getTypeByName to return null.  The currentCurrencyMap will then have an asset with key equal to null, which should never happen.  That will later cause a crash in CurrencySwitcher.setCurrency.  This fix here is to use the BTC coin type as the default instead of returning null.
@kurtnebiev-elvis4
Copy link
Contributor

If an unknown coin type is read from user data, it will cause getTypeByName to return null. The currentCurrencyMap will then have an asset with key equal to null, which should never happen. That will later cause a crash in CurrencySwitcher.setCurrency. This fix here is to use the BTC coin type as the default instead of returning null.

Its not reason to return BTC for every unknown coin. It will produce not correct behavior. Should handle maybe with exception or handle null in concrete place.

@Raystonn
Copy link
Author

Raystonn commented Dec 11, 2024 via email

@kurtnebiev-elvis4
Copy link
Contributor

If preferred we can instead allocate a new CryptoCurrency object with the name that was passed to the function and some default properties.

I like this idea with new Unknown CryptoCurrency object.

If an unknown coin type is read from user data, it will cause getTypeByName to return null. The currentCurrencyMap will then have an asset with key equal to null, which should never happen. That will later cause a crash in CurrencySwitcher.setCurrency. The fix here is to allocate a new Unknown CryptoCurrency object instead of returning null.
@Raystonn
Copy link
Author

I have updated the pull request with the discussed changes. Thank you for the review!

@Raystonn
Copy link
Author

Raystonn commented Jan 6, 2025

How long do reviewed pull requests usually take to be completed in this project?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants