From: Steve MacLean, Qualcomm Datacenter Technologies, Inc Date: Wed, 29 Mar 2017 21:07:26 +0000 (+0000) Subject: Handle null ref in Compiler::optCreateAssertion X-Git-Tag: submit/tizen/20210909.063632~11030^2~7488^2~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=9eb2045d6f38a4b7d1dafd14e558219545efd44d;p=platform%2Fupstream%2Fdotnet%2Fruntime.git Handle null ref in Compiler::optCreateAssertion Code as recommended by Eugene Rozenfeld in dotnet/coreclr#10359 Fixes dotnet/coreclr#10359 Commit migrated from https://github.com/dotnet/coreclr/commit/03e9fd77c9ff5933b47e9e2bdce825eaa6e47eba --- diff --git a/src/coreclr/src/jit/assertionprop.cpp b/src/coreclr/src/jit/assertionprop.cpp index 87aa946..423a8a6 100644 --- a/src/coreclr/src/jit/assertionprop.cpp +++ b/src/coreclr/src/jit/assertionprop.cpp @@ -947,12 +947,12 @@ AssertionIndex Compiler::optCreateAssertion(GenTreePtr op1, while (vnStore->GetVNFunc(vn, &funcAttr) && (funcAttr.m_func == (VNFunc)GT_ADD) && (vnStore->TypeOfVN(vn) == TYP_BYREF)) { - if (vnStore->IsVNConstant(funcAttr.m_args[1])) + if (vnStore->IsVNConstant(funcAttr.m_args[1]) && varTypeIsIntegral(vnStore->TypeOfVN(funcAttr.m_args[1]))) { offset += vnStore->CoercedConstantValue(funcAttr.m_args[1]); vn = funcAttr.m_args[0]; } - else if (vnStore->IsVNConstant(funcAttr.m_args[0])) + else if (vnStore->IsVNConstant(funcAttr.m_args[0]) && varTypeIsIntegral(vnStore->TypeOfVN(funcAttr.m_args[0]))) { offset += vnStore->CoercedConstantValue(funcAttr.m_args[0]); vn = funcAttr.m_args[1];