From d121ad986546f1a0f4c25cf3c41d2f7b595108fb Mon Sep 17 00:00:00 2001 From: Jb Evain Date: Wed, 30 Aug 2017 14:14:59 -0700 Subject: Protect against null variable and constant debug information --- Mono.Cecil/AssemblyReader.cs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/Mono.Cecil/AssemblyReader.cs b/Mono.Cecil/AssemblyReader.cs index 654bf48..7ae6e55 100644 --- a/Mono.Cecil/AssemblyReader.cs +++ b/Mono.Cecil/AssemblyReader.cs @@ -2943,14 +2943,20 @@ namespace Mono.Cecil { if (record.Col2.Length > 0) { scope.variables = new Collection ((int) record.Col2.Length); - for (uint i = 0; i < record.Col2.Length; i++) - scope.variables.Add (ReadLocalVariable (record.Col2.Start + i)); + for (uint i = 0; i < record.Col2.Length; i++) { + var variable = ReadLocalVariable (record.Col2.Start + i); + if (variable != null) + scope.variables.Add (variable); + } } if (record.Col3.Length > 0) { scope.constants = new Collection ((int) record.Col3.Length); - for (uint i = 0; i < record.Col3.Length; i++) - scope.constants.Add (ReadLocalConstant (record.Col3.Start + i)); + for (uint i = 0; i < record.Col3.Length; i++) { + var constant = ReadLocalConstant (record.Col3.Start + i); + if (constant != null) + scope.constants.Add (constant); + } } return scope; -- cgit v1.2.3