diff --git a/Mono.Cecil/AssemblyReader.cs b/Mono.Cecil/AssemblyReader.cs index 4564071e8..5c3effb4d 100644 --- a/Mono.Cecil/AssemblyReader.cs +++ b/Mono.Cecil/AssemblyReader.cs @@ -987,8 +987,10 @@ Range ReadListRange (uint current_index, Table current, Table target) uint next_index; var current_table = image.TableHeap [current]; + var last_index = image.TableHeap [target].Length + 1; + if (current_index == current_table.Length) - next_index = image.TableHeap [target].Length + 1; + next_index = last_index; else { var position = this.position; this.position += (int) (current_table.RowSize - image.GetTableIndexSize (target)); @@ -996,6 +998,10 @@ Range ReadListRange (uint current_index, Table current, Table target) this.position = position; } + if (next_index == 0 && current_index + 1 == current_table.Length && image.TableHeap [target].Length == 0xffff) { + next_index = last_index; + } + list.Start = start; list.Length = next_index - start; diff --git a/Test/Mono.Cecil.Tests/ParameterTests.cs b/Test/Mono.Cecil.Tests/ParameterTests.cs index 5ec3e0637..fa247d63b 100644 --- a/Test/Mono.Cecil.Tests/ParameterTests.cs +++ b/Test/Mono.Cecil.Tests/ParameterTests.cs @@ -270,5 +270,17 @@ public void NullablePrimitiveParameterConstant () Assert.AreEqual (12, param.Constant); }); } + + [Test] + public void ModuleWith0xFFFFParameters () + { + TestModule ("param0xffff.dll", module => { + var test = module.GetType ("Program"); + var method = test.GetMethod ("F_65534"); + + Assert.AreEqual (1, method.Parameters.Count); + Assert.AreEqual ("a", method.Parameters [0].Name); + }, verify: false); + } } } diff --git a/Test/Resources/assemblies/param0xffff.dll b/Test/Resources/assemblies/param0xffff.dll new file mode 100644 index 000000000..c6a889a8e Binary files /dev/null and b/Test/Resources/assemblies/param0xffff.dll differ