Skip to content

Commit e55d803

Browse files
committed
Fix merge with master
1 parent 220c19e commit e55d803

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

Mono.Cecil.PE/ByteBuffer.cs

+5
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,11 @@ public PByteBuffer (ByteSpan span)
4343
this.e = this.p + this.span.length;
4444
}
4545

46+
public int RemainingBytes ()
47+
{
48+
return (int) (e - p);
49+
}
50+
4651
public bool CanReadMore ()
4752
{
4853
return p < e;

Mono.Cecil/AssemblyReader.cs

+4-10
Original file line numberDiff line numberDiff line change
@@ -2288,7 +2288,7 @@ MethodSpecification ReadMethodSpecSignature (uint signature, MethodReference met
22882288
if (call_conv != methodspec_sig)
22892289
throw new NotSupportedException ();
22902290

2291-
var arity = reader.ReadCompressedUInt32 ();
2291+
var arity = sig.ReadCompressedUInt32 ();
22922292

22932293
var instance = new GenericInstanceMethod (method, (int) arity);
22942294

@@ -3430,10 +3430,10 @@ TypeReference ReadTypeSignature (ElementType etype, ref PByteBuffer buffer)
34303430
var is_value_type = buffer.ReadByte () == (byte) ElementType.ValueType;
34313431
var element_type = GetTypeDefOrRef (ReadTypeTokenSignature (ref buffer));
34323432

3433-
var arity = ReadCompressedUInt32 ();
3433+
var arity = buffer.ReadCompressedUInt32 ();
34343434
var generic_instance = new GenericInstanceType (element_type);
34353435

3436-
ReadGenericInstanceSignature (element_type, generic_instance, arity ref buffer);
3436+
ReadGenericInstanceSignature (element_type, generic_instance, arity, ref buffer);
34373437

34383438
if (is_value_type) {
34393439
generic_instance.KnownValueType ();
@@ -3833,8 +3833,7 @@ public Collection<SequencePoint> ReadSequencePoints (Document document, ref PByt
38333833
//there's about 5 compressed int32's per sequence points. we don't know exactly how many
38343834
//but let's take a conservative guess so we dont end up reallocating the sequence_points collection
38353835
//as it grows.
3836-
var bytes_remaining_for_sequencepoints = sig_length - (position - start);
3837-
var estimated_sequencepoint_amount = (int)bytes_remaining_for_sequencepoints / 5;
3836+
var estimated_sequencepoint_amount = (int) buffer.RemainingBytes () / 5;
38383837
var sequence_points = new Collection<SequencePoint> (estimated_sequencepoint_amount);
38393838

38403839
for (var i = 0; buffer.CanReadMore (); i++) {
@@ -3880,10 +3879,5 @@ public Collection<SequencePoint> ReadSequencePoints (Document document, ref PByt
38803879

38813880
return sequence_points;
38823881
}
3883-
3884-
public bool CanReadMore ()
3885-
{
3886-
return (position - start) < sig_length;
3887-
}
38883882
}
38893883
}

0 commit comments

Comments
 (0)