Skip to content

Commit 21be2fb

Browse files
committed
[clang-tidy][NFC] Fix buffer overflow in modernize-use-designated-initializers
Instance of DenseMap were copied into local variable, and as a result reference to string stored in that local variable were returned from function. At the end fix-it were applied with already destroyed string causing some non utf-8 characters to be printed. Related to #80541
1 parent cff36bb commit 21be2fb

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

clang-tools-extra/clang-tidy/modernize/UseDesignatedInitializersCheck.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ struct Designators {
4343
unsigned size() { return getCached().size(); }
4444

4545
std::optional<llvm::StringRef> operator[](const SourceLocation &Location) {
46-
const auto Designators = getCached();
46+
const auto &Designators = getCached();
4747
const auto Result = Designators.find(Location);
4848
if (Result == Designators.end())
4949
return {};

0 commit comments

Comments
 (0)