diff options
author | Rafael Auler <rafaelauler@fb.com> | 2023-01-25 11:38:07 -0800 |
---|---|---|
committer | Tobias Hieta <tobias@hieta.se> | 2023-03-28 08:55:06 +0200 |
commit | c2ef3257df81b8e3f5f4313939ff536a81d7cde0 (patch) | |
tree | 736a19ec0a6c0e16b09fbec7463cb68ec04407b4 | |
parent | 1c1ab11d6e1e45a49fd543fa485d2b1701487e06 (diff) | |
download | llvm-c2ef3257df81b8e3f5f4313939ff536a81d7cde0.tar.gz |
[BOLT][NFC] Remove C-style out of bounds array ref
Old code breaks build with libstdc++ with assertions. Fix it.
(cherry picked from commit 7768f63e5b7adc8a92b8f8041e9c1d298b011128)
-rw-r--r-- | bolt/lib/Core/JumpTable.cpp | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/bolt/lib/Core/JumpTable.cpp b/bolt/lib/Core/JumpTable.cpp index 2b1035d6ab71..65e1032c579b 100644 --- a/bolt/lib/Core/JumpTable.cpp +++ b/bolt/lib/Core/JumpTable.cpp @@ -70,12 +70,10 @@ bool bolt::JumpTable::replaceDestination(uint64_t JTAddress, MCSymbol *NewDest) { bool Patched = false; const std::pair<size_t, size_t> Range = getEntriesForAddress(JTAddress); - for (auto I = &Entries[Range.first], E = &Entries[Range.second]; I != E; - ++I) { - MCSymbol *&Entry = *I; - if (Entry == OldDest) { + for (auto I = Range.first; I != Range.second; ++I) { + if (Entries[I] == OldDest) { Patched = true; - Entry = NewDest; + Entries[I] = NewDest; } } return Patched; |