aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Object/ELF.cpp
diff options
context:
space:
mode:
authorRahman Lavaee <rahmanl@google.com>2024-11-12 17:49:56 +0000
committerGitHub <noreply@github.com>2024-11-12 09:49:56 -0800
commit789de766b5fc9c8ffa6e808a8baf0e585ac2e818 (patch)
tree0669d5f79a5e81fbc4e8e9dd788eccf500784065 /llvm/lib/Object/ELF.cpp
parent2c6424e691e32f79bc303203deb1c91634d62286 (diff)
downloadllvm-789de766b5fc9c8ffa6e808a8baf0e585ac2e818.zip
llvm-789de766b5fc9c8ffa6e808a8baf0e585ac2e818.tar.gz
llvm-789de766b5fc9c8ffa6e808a8baf0e585ac2e818.tar.bz2
[NFC,SHT_LLVM_BB_ADDR_MAP] Fix undefined behaviour in ELF.cpp. (#115830)
`BBEntries` is defined outside of the loop and is used after move which is undefined behavior.
Diffstat (limited to 'llvm/lib/Object/ELF.cpp')
-rw-r--r--llvm/lib/Object/ELF.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/llvm/lib/Object/ELF.cpp b/llvm/lib/Object/ELF.cpp
index 9a9e762..545a672 100644
--- a/llvm/lib/Object/ELF.cpp
+++ b/llvm/lib/Object/ELF.cpp
@@ -823,7 +823,6 @@ decodeBBAddrMapImpl(const ELFFile<ELFT> &EF,
uint32_t NumBlocksInBBRange = 0;
uint32_t NumBBRanges = 1;
typename ELFFile<ELFT>::uintX_t RangeBaseAddress = 0;
- std::vector<BBAddrMap::BBEntry> BBEntries;
if (FeatEnable.MultiBBRange) {
NumBBRanges = readULEB128As<uint32_t>(Data, Cur, ULEBSizeErr);
if (!Cur || ULEBSizeErr)
@@ -851,6 +850,7 @@ decodeBBAddrMapImpl(const ELFFile<ELFT> &EF,
RangeBaseAddress = *AddressOrErr;
NumBlocksInBBRange = readULEB128As<uint32_t>(Data, Cur, ULEBSizeErr);
}
+ std::vector<BBAddrMap::BBEntry> BBEntries;
for (uint32_t BlockIndex = 0; !MetadataDecodeErr && !ULEBSizeErr && Cur &&
(BlockIndex < NumBlocksInBBRange);
++BlockIndex) {