Skip to content

Commit b06f5e1

Browse files
authored
Add check for string table size (#164)
1 parent afeb642 commit b06f5e1

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

MetadataProcessor.Shared/Tables/nanoStringTable.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,13 @@ public ushort GetOrCreateStringId(
9999
id = _lastAvailableId;
100100
_idsByStrings.Add(value, id);
101101
var length = Encoding.UTF8.GetBytes(value).Length + 1;
102+
103+
// sanity check for ID overflow
104+
if (_lastAvailableId + length > ushort.MaxValue)
105+
{
106+
throw new InvalidOperationException($"String table overflow in assembly '{_context.AssemblyDefinition.Name}'. Can't use so many strings.");
107+
}
108+
102109
_lastAvailableId += (ushort)(length);
103110
}
104111
return id;

0 commit comments

Comments
 (0)