From 81ae5098552e7e643cdc750f2b7eb99e9bfea7fa 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 8217bc0..02d7787 100644 --- a/Mono.Cecil/AssemblyReader.cs +++ b/Mono.Cecil/AssemblyReader.cs @@ -2954,14 +2954,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