From 061471285efe0941b38932e94c548779f85fd31d Mon Sep 17 00:00:00 2001 From: Aleksandr Dovydenkov Date: Fri, 7 Aug 2026 14:30:54 +0300 Subject: [PATCH] =?UTF-8?q?Add=20defensive=20null=E2=80=91check=20for=20pT?= =?UTF-8?q?argetMD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Check before accessing pTargetMD prevents a potential dereference if the target method descriptor is not supplied, while preserving the existing assertion and token‑writing logic. --- src/coreclr/vm/tailcallhelp.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/coreclr/vm/tailcallhelp.cpp b/src/coreclr/vm/tailcallhelp.cpp index 92efd671e2a6d0..be704534fd51c9 100644 --- a/src/coreclr/vm/tailcallhelp.cpp +++ b/src/coreclr/vm/tailcallhelp.cpp @@ -297,7 +297,7 @@ bool TailCallHelp::GenerateGCDescriptor( { #ifndef TARGET_X86 // The generic instantiation arg is right after this pointer - if (reportInstArg) + if (reportInstArg && pTargetMD) { _ASSERTE(i == 0 || i == 1); builder->WriteToken(argPos, pTargetMD->RequiresInstMethodDescArg() ? GCREFMAP_METHOD_PARAM : GCREFMAP_TYPE_PARAM); @@ -326,7 +326,7 @@ bool TailCallHelp::GenerateGCDescriptor( #ifdef TARGET_X86 // The generic instantiation arg is last - if (reportInstArg) + if (reportInstArg && pTargetMD) { const ArgBufferValue& val = layout.Values[layout.Values.GetCount() - 1]; unsigned int argPos = (val.Offset - offsetof(TailCallArgBuffer, Args)) / TARGET_POINTER_SIZE;