Compiler::lookupHWIntrinsic: fix oob read (dotnet/coreclr#16075)
authorKonstantin Baladurin <k.baladurin@partner.samsung.com>
Tue, 30 Jan 2018 15:23:16 +0000 (18:23 +0300)
committerJan Vorlicek <janvorli@microsoft.com>
Tue, 30 Jan 2018 15:23:16 +0000 (16:23 +0100)
Commit migrated from https://github.com/dotnet/coreclr/commit/6fc51589a9be3ec12bf8ed5336e415431f01b6ac

src/coreclr/src/jit/hwintrinsicxarch.cpp

index d8ac1ae..09e3c72 100644 (file)
@@ -132,7 +132,7 @@ NamedIntrinsic Compiler::lookupHWIntrinsic(const char* methodName, InstructionSe
     NamedIntrinsic result = NI_Illegal;
     if (isa != InstructionSet_ILLEGAL)
     {
-        for (int i = 0; i < NI_HW_INTRINSIC_END - NI_HW_INTRINSIC_START; i++)
+        for (int i = 0; i < NI_HW_INTRINSIC_END - NI_HW_INTRINSIC_START - 1; i++)
         {
             if (isa == hwIntrinsicInfoArray[i].isa && strcmp(methodName, hwIntrinsicInfoArray[i].intrinsicName) == 0)
             {