diff options
author | Yuxuan Chen <ych@fb.com> | 2024-07-10 11:24:23 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-07-10 11:24:23 -0700 |
commit | 6f13c71d31f7aa08bd59c72f7ba4c5c8b1023e40 (patch) | |
tree | facfe5bcf5305fbd588b1eb61a7b3b93cbfdff48 /clang/lib/Sema/SemaInit.cpp | |
parent | 1f819f0a79d15ac2ea845186e7396499dd474f57 (diff) | |
download | llvm-6f13c71d31f7aa08bd59c72f7ba4c5c8b1023e40.zip llvm-6f13c71d31f7aa08bd59c72f7ba4c5c8b1023e40.tar.gz llvm-6f13c71d31f7aa08bd59c72f7ba4c5c8b1023e40.tar.bz2 |
[clang] fix sema init crashing on initialization sequences (#98102)
We ran into a FE crash and root caused to `ER.get()` on line 5584 here
being nullptr. I think this is a result of not checking if ER here is
invalid.
Example of crash-on-valid C++
https://gist.github.com/yuxuanchen1997/576dce964666f0f8713fccacf5847138
Note that this crash happens only with `-std=c++20`.
Diffstat (limited to 'clang/lib/Sema/SemaInit.cpp')
-rw-r--r-- | clang/lib/Sema/SemaInit.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaInit.cpp b/clang/lib/Sema/SemaInit.cpp index 41753a1..a27ed02 100644 --- a/clang/lib/Sema/SemaInit.cpp +++ b/clang/lib/Sema/SemaInit.cpp @@ -5576,6 +5576,10 @@ static void TryOrBuildParenListInitialization( ExprResult ER; ER = IS.Perform(S, SubEntity, SubKind, Arg ? MultiExprArg(Arg) : std::nullopt); + + if (ER.isInvalid()) + return false; + if (InitExpr) *InitExpr = ER.get(); else |