Skip to content

Commit 5e54eb1

Browse files
committed
[Diagnostics] Use constant strings to avoid use after free.
Using std::string in the function signature copies the constant string into a stack allocated copy, which is the one referenced by the StringRef that DiagnosticInfo stores. when the stack is abandoned, the string seems to be modificed in VC++, which makes the test fail in Windows. Using const char * in the signature avoids the std::string creation, and StringRef will refer to the static data instead.
1 parent 7b90628 commit 5e54eb1

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

unittests/AST/DiagnosticConsumerTests.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ namespace {
5050
}
5151
};
5252

53-
DiagnosticInfo testDiagnosticInfo(SourceLoc Loc, std::string Message,
53+
DiagnosticInfo testDiagnosticInfo(SourceLoc Loc, const char *Message,
5454
DiagnosticKind Kind) {
5555
return DiagnosticInfo(DiagID(0), Loc, Kind, Message, /*args*/ {},
5656
/*indirectBuffer*/ SourceLoc(), /*childInfo*/ {},

0 commit comments

Comments
 (0)