feat(lint): add missing-zero-check#14460
Open
stevencartavia wants to merge 6 commits intomasterfrom
Open
Conversation
mablr
reviewed
Apr 27, 2026
mablr
reviewed
Apr 27, 2026
Comment on lines
+193
to
+201
| StmtKind::If(cond, then, else_) => { | ||
| self.guard_depth += 1; | ||
| let _ = self.visit_expr(cond); | ||
| self.guard_depth -= 1; | ||
| let _ = self.visit_stmt(then); | ||
| if let Some(e) = else_ { | ||
| let _ = self.visit_stmt(e); | ||
| } | ||
| return ControlFlow::Continue(()); |
Collaborator
There was a problem hiding this comment.
Guard is not path sensitive, idk if there's a simple way to fix it, at least we should document this limitation.
This should trigger a warning, but it doesn't
function guardOnOneBranch(address a, bool flag) external {
if (flag) {
require(a != address(0)); // only guards when flag==true
}
owner = a; // sink reachable unchecked when flag==false
}
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds a
missing-zero-checklint that flags address parameters of externally-callable functions and constructors used in state writes or value transfers(call/delegatecall/staticcall/transfer/send)without a priorrequire/assert/ifcheck.Testing
cargo run -p forge -- lint crates/lint/testdata/MissingZeroCheck.sol