Fix ubsan bounds check failure.

llvm-svn: 332866
This commit is contained in:
Peter Collingbourne 2018-05-21 19:09:47 +00:00
parent f14e62c9a5
commit 2602a0d40c
1 changed files with 2 additions and 1 deletions

View File

@ -365,7 +365,8 @@ bool X86AsmBackend::writeNopData(raw_ostream &OS, uint64_t Count) const {
for (uint8_t i = 0; i < Prefixes; i++)
OS << '\x66';
const uint8_t Rest = ThisNopLength - Prefixes;
OS.write(Nops[Rest - 1], Rest);
if (Rest != 0)
OS.write(Nops[Rest - 1], Rest);
Count -= ThisNopLength;
} while (Count != 0);