[llvm] 6d90c59 - [JITLink] Don't initialize local ArrayRefs with initializer lists.
Lang Hames via llvm-commits
llvm-commits at lists.llvm.org
Sat Feb 11 17:15:27 PST 2023
Author: Lang Hames
Date: 2023-02-11T17:13:25-08:00
New Revision: 6d90c590b7f5a215d4c73a298336ddf005f65ce3
URL: https://github.com/llvm/llvm-project/commit/6d90c590b7f5a215d4c73a298336ddf005f65ce3
DIFF: https://github.com/llvm/llvm-project/commit/6d90c590b7f5a215d4c73a298336ddf005f65ce3.diff
LOG: [JITLink] Don't initialize local ArrayRefs with initializer lists.
This can lead to use-after-free errors (see e.g.
https://lab.llvm.org/buildbot/#/builders/168/builds/11848).
Added:
Modified:
llvm/unittests/ExecutionEngine/JITLink/LinkGraphTests.cpp
Removed:
################################################################################
diff --git a/llvm/unittests/ExecutionEngine/JITLink/LinkGraphTests.cpp b/llvm/unittests/ExecutionEngine/JITLink/LinkGraphTests.cpp
index 90353b542869..80f557122ec2 100644
--- a/llvm/unittests/ExecutionEngine/JITLink/LinkGraphTests.cpp
+++ b/llvm/unittests/ExecutionEngine/JITLink/LinkGraphTests.cpp
@@ -721,9 +721,9 @@ TEST(LinkGraphTest, GraphAllocationMethods) {
EXPECT_EQ(Buf1.size(), 10U);
// Test allocation of content-backed buffer.
- ArrayRef<char> Buf2Src = {1, static_cast<char>(-1), 0, 42};
- auto Buf2 = G.allocateContent(Buf2Src);
- EXPECT_EQ(Buf2, Buf2Src);
+ char Buf2Src[] = {1, static_cast<char>(-1), 0, 42};
+ auto Buf2 = G.allocateContent(ArrayRef<char>(Buf2Src));
+ EXPECT_EQ(Buf2, ArrayRef<char>(Buf2Src));
// Test c-string allocation from StringRef.
StringRef Buf3Src = "hello";
@@ -739,8 +739,8 @@ TEST(LinkGraphTest, IsCStringBlockTest) {
auto &Sec =
G.createSection("__data", orc::MemProt::Read | orc::MemProt::Write);
- ArrayRef<char> CString = "hello, world!";
- ArrayRef<char> NotACString = {0, 1, 0, 1, 0};
+ char CString[] = "hello, world!";
+ char NotACString[] = {0, 1, 0, 1, 0};
auto &CStringBlock =
G.createContentBlock(Sec, CString, orc::ExecutorAddr(), 1, 0);
More information about the llvm-commits
mailing list