OSDN Git Service

Fix ubsan bounds check failure.
authorPeter Collingbourne <peter@pcc.me.uk>
Mon, 21 May 2018 19:09:47 +0000 (19:09 +0000)
committerPeter Collingbourne <peter@pcc.me.uk>
Mon, 21 May 2018 19:09:47 +0000 (19:09 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@332866 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp

index 7b6ff13..8efb284 100644 (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);