Skip to content

Commit 6b67fcd

Browse files
Check length of TypeArguments before accessing via index
1 parent f31188b commit 6b67fcd

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/Framework/AspNetCoreAnalyzers/src/Analyzers/RouteHandlers/DisallowNonParsableComplexTypesOnParameters.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,8 @@ static bool ReportFromAttributeDiagnostic(OperationAnalysisContext context, Well
128128
}
129129

130130
// If it is nullable, unwrap it.
131-
if (parameterTypeSymbol!.ConstructedFrom.SpecialType == SpecialType.System_Nullable_T)
131+
if (parameterTypeSymbol!.ConstructedFrom.SpecialType == SpecialType.System_Nullable_T &&
132+
parameterTypeSymbol.TypeArguments.Length > 0)
132133
{
133134
parameterTypeSymbol = parameterTypeSymbol.TypeArguments[0] as INamedTypeSymbol;
134135
}

0 commit comments

Comments
 (0)