Skip to content

Commit 4377485

Browse files
committed
Improve comments and add sanity check
1 parent af28380 commit 4377485

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/CLR/Core/TypeSystem.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4586,13 +4586,20 @@ bool CLR_RT_Assembly::FindGenericParamAtTypeSpec(
45864586

45874587
CLR_RT_SignatureParser::Element element;
45884588

4589-
// first Advance() steps into the VAR signature…
4589+
// get into the GENERICINST
45904590
if (FAILED(parser.Advance(element)))
45914591
{
45924592
return false;
45934593
}
45944594

4595-
// walk to the Nth parameter
4595+
// sanity check for invalid parameter position
4596+
if (genericParameterPosition > parser.GenParamCount)
4597+
{
4598+
// not enough parameters!!
4599+
return false;
4600+
}
4601+
4602+
// walk to the requested parameter position
45964603
for (uint32_t i = 0; i <= genericParameterPosition; i++)
45974604
{
45984605
if (FAILED(parser.Advance(element)))

0 commit comments

Comments
 (0)