Skip to content

Commit 9cebf0a

Browse files
authored
Merge pull request #6533 from DougGregor/diag-use-after-free
[Type checker] Fix a use-after-free due to StringRefs stored in DiagnosticArguments.
2 parents adb05f5 + a202795 commit 9cebf0a

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

lib/Sema/TypeCheckConstraints.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2926,9 +2926,10 @@ CheckedCastKind TypeChecker::typeCheckCheckedCast(Type fromType,
29262926
llvm_unreachable("suppressing diagnostics");
29272927

29282928
case CheckedCastContextKind::ForcedCast: {
2929+
std::string extraFromOptionalsStr(extraFromOptionals, '!');
29292930
auto diag = diagnose(diagLoc, diag::downcast_same_type,
29302931
origFromType, origToType,
2931-
std::string(extraFromOptionals, '!'),
2932+
extraFromOptionalsStr,
29322933
isBridged);
29332934
diag.highlight(diagFromRange);
29342935
diag.highlight(diagToRange);

0 commit comments

Comments
 (0)