-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[NFC] Avoid potential null dereference. #126872
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
Merged
Merged
Conversation
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
@llvm/pr-subscribers-clang-format Author: None (schittir) ChangesAdd a null check. Full diff: https://github.com/llvm/llvm-project/pull/126872.diff 1 Files Affected:
diff --git a/clang/lib/Format/UnwrappedLineFormatter.cpp b/clang/lib/Format/UnwrappedLineFormatter.cpp
index 46545aa1f4c07..a5b30c85974c7 100644
--- a/clang/lib/Format/UnwrappedLineFormatter.cpp
+++ b/clang/lib/Format/UnwrappedLineFormatter.cpp
@@ -1596,7 +1596,7 @@ static auto computeNewlines(const AnnotatedLine &Line,
if (Line.startsWith(TT_NamespaceRBrace)) {
if (Style.WrapNamespaceBodyWithEmptyLines == FormatStyle::WNBWELS_Never)
Newlines = 1;
- else if (!PreviousLine->startsWith(TT_NamespaceRBrace))
+ else if (PreviousLine && !PreviousLine->startsWith(TT_NamespaceRBrace))
Newlines = std::max(Newlines, 2u);
}
}
|
hstk30-hw
approved these changes
Feb 12, 2025
@schittir please add a test case that would cause a crash without your patch. |
flovent
pushed a commit
to flovent/llvm-project
that referenced
this pull request
Feb 13, 2025
Add a null check.
schittir
added a commit
that referenced
this pull request
Feb 14, 2025
Reverts #126872 The commit, though harmless, is unnecessary.
github-actions bot
pushed a commit
to arm/arm-toolchain
that referenced
this pull request
Feb 14, 2025
Reverts llvm/llvm-project#126872 The commit, though harmless, is unnecessary.
joaosaffran
pushed a commit
to joaosaffran/llvm-project
that referenced
this pull request
Feb 14, 2025
Add a null check.
joaosaffran
pushed a commit
to joaosaffran/llvm-project
that referenced
this pull request
Feb 14, 2025
Reverts llvm#126872 The commit, though harmless, is unnecessary.
sivan-shani
pushed a commit
to sivan-shani/llvm-project
that referenced
this pull request
Feb 24, 2025
Add a null check.
sivan-shani
pushed a commit
to sivan-shani/llvm-project
that referenced
this pull request
Feb 24, 2025
Reverts llvm#126872 The commit, though harmless, is unnecessary.
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.
Add a null check.