Skip to content

Commit aba8387

Browse files
Add check for byte code table size (#170)
1 parent 6ee2961 commit aba8387

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

MetadataProcessor.Shared/Tables/nanoByteCodeTable.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,12 @@ public ushort GetMethodId(
8282

8383
var byteCode = CreateByteCode(method);
8484

85+
// sanity check for RVA overflow
86+
if (_lastAvailableRva + byteCode.Length > ushort.MaxValue)
87+
{
88+
throw new InvalidOperationException($"Byte code table overflow in assembly '{_context.AssemblyDefinition.Name}'. It's impossible to compile such a large assembly.");
89+
}
90+
8591
_methods.Add(method);
8692
_lastAvailableRva += (ushort)byteCode.Length;
8793

@@ -161,3 +167,4 @@ private byte[] CreateByteCode(
161167
}
162168
}
163169
}
170+

0 commit comments

Comments
 (0)