-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Null checks before dereferencing a pointer #643
Comments
It seems that (haven't yet grasped all of the different checks here and what each one does under different flags) |
Good catch. If we check it, then we should check it before we dereference it... (Otherwise the compiler may just remove the check.) Do you want to open a PR? Different checks:
For the usage see #566 (comment), it's not 100% consistent throughout the library, and there are cases where it's not 100% clear what the right check is. As I interpret this guideline, it will acceptable to replace the VERIFY_CHECK by a CHECK here. But for the sake of doing only a minimal change, I recommend leaving it as it is and not caring too much about it. |
Sure, opened a PR. |
94ae7cb Moved a dereference so the null check will be before the dereferencing (Elichai Turkel) Pull request description: Before that even on debug the compiler could've assumed `a` isn't null and optimized `VERIFY_CHECK(a != NULL);` out. This put the dereference after the check Resolves #643 ACKs for commit 94ae7c: sipa: ACK 94ae7cb Tree-SHA512: 8b986f202ede5bde1f14a8ecf25e339d64ee6cd5cb391c5f18b4ff58f946c3845902d1230bc80d110a0a33b37025d281bd4532afbdf03b1c9ca321097374eb8e
Hi,
As far as I could see this doesn't currently affect anything in the code but there's a pointer dereference here:
https://github.com/bitcoin-core/secp256k1/blob/master/src/ecmult_impl.h#L398
and only a few lines afterwards we check if it's not null
https://github.com/bitcoin-core/secp256k1/blob/master/src/ecmult_impl.h#L406
The text was updated successfully, but these errors were encountered: