[clang-tools-extra] 21be2fb - [clang-tidy][NFC] Fix buffer overflow in modernize-use-designated-initializers
Piotr Zegar via cfe-commits
cfe-commits at lists.llvm.org
Thu Feb 29 12:54:28 PST 2024
Author: Piotr Zegar
Date: 2024-02-29T20:53:30Z
New Revision: 21be2fbd17f9ff6f3f04e0ababc91c9cdd5aed85
URL: https://github.com/llvm/llvm-project/commit/21be2fbd17f9ff6f3f04e0ababc91c9cdd5aed85
DIFF: https://github.com/llvm/llvm-project/commit/21be2fbd17f9ff6f3f04e0ababc91c9cdd5aed85.diff
LOG: [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
Added:
Modified:
clang-tools-extra/clang-tidy/modernize/UseDesignatedInitializersCheck.cpp
Removed:
################################################################################
diff --git a/clang-tools-extra/clang-tidy/modernize/UseDesignatedInitializersCheck.cpp b/clang-tools-extra/clang-tidy/modernize/UseDesignatedInitializersCheck.cpp
index 9ff6bb15043b54..ebc5338d0a7bfa 100644
--- a/clang-tools-extra/clang-tidy/modernize/UseDesignatedInitializersCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/UseDesignatedInitializersCheck.cpp
@@ -43,7 +43,7 @@ struct Designators {
unsigned size() { return getCached().size(); }
std::optional<llvm::StringRef> operator[](const SourceLocation &Location) {
- const auto Designators = getCached();
+ const auto &Designators = getCached();
const auto Result = Designators.find(Location);
if (Result == Designators.end())
return {};
More information about the cfe-commits
mailing list