Skip to content

Commit 789de76

Browse files
authored
[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.
1 parent 2c6424e commit 789de76

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

llvm/lib/Object/ELF.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -823,7 +823,6 @@ decodeBBAddrMapImpl(const ELFFile<ELFT> &EF,
823823
uint32_t NumBlocksInBBRange = 0;
824824
uint32_t NumBBRanges = 1;
825825
typename ELFFile<ELFT>::uintX_t RangeBaseAddress = 0;
826-
std::vector<BBAddrMap::BBEntry> BBEntries;
827826
if (FeatEnable.MultiBBRange) {
828827
NumBBRanges = readULEB128As<uint32_t>(Data, Cur, ULEBSizeErr);
829828
if (!Cur || ULEBSizeErr)
@@ -851,6 +850,7 @@ decodeBBAddrMapImpl(const ELFFile<ELFT> &EF,
851850
RangeBaseAddress = *AddressOrErr;
852851
NumBlocksInBBRange = readULEB128As<uint32_t>(Data, Cur, ULEBSizeErr);
853852
}
853+
std::vector<BBAddrMap::BBEntry> BBEntries;
854854
for (uint32_t BlockIndex = 0; !MetadataDecodeErr && !ULEBSizeErr && Cur &&
855855
(BlockIndex < NumBlocksInBBRange);
856856
++BlockIndex) {

0 commit comments

Comments
 (0)