trustwallet / wallet-core

Cross-platform, cross-blockchain wallet library.
https://developer.trustwallet.com/wallet-core
Apache License 2.0
2.79k stars 1.57k forks source link

Fix nullptr dereference when not calling JNI_OnLoad on Android #3984

Closed henriqueaklein closed 1 month ago

henriqueaklein commented 1 month ago

This change is applicable to loading the wallet-core on Android using the library directly instead of JNI. Without calling JNI_OnLoad the jvm pointer is NULL, so any attempt to use it in random_buffer will result in a nullptr dereference.

In addition to preventing the crash, the Unix compatible implementation was used as an alternative when using the library directly.