Skip to content

Commit

Permalink
protect against broken custom field declarations
Browse files Browse the repository at this point in the history
  • Loading branch information
omkelderman committed Apr 15, 2023
1 parent ed92f2d commit a4fb0ae
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,15 @@ public IEnumerable<Collection> ReadOsdb(string fullFileDir, MapCacher mapCacher)
Type = (CustomFieldType)_binReader.ReadByte(),
DisplayText = _binReader.ReadString(),
};
customFieldDefinitions.Add(key, def);
try
{
customFieldDefinitions.Add(key, def);
}
catch (ArgumentException)
{
// custom field key is already used
throw new CorruptedFileException($"Collection declared multiple custom fields with the same key");
}
}
}

Expand Down

0 comments on commit a4fb0ae

Please sign in to comment.