From 81dcbfb9a16247a59ae3d37b6b556fa5962995a0 Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Wed, 22 Sep 2021 20:33:11 +0200 Subject: [PATCH] Fixed DynamicEnum AddFlag going into an infinite loop --- CHANGELOG.md | 3 +++ MLEM.Data/DynamicEnum.cs | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c12703b..794a45b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -51,6 +51,9 @@ Improvements - Improved CopyExtensions construction speed - Improved DynamicEnum caching +Fixes +- Fixed DynamicEnum AddFlag going into an infinite loop + ## 5.0.0 ### MLEM Additions diff --git a/MLEM.Data/DynamicEnum.cs b/MLEM.Data/DynamicEnum.cs index 66de417..b57aabf 100644 --- a/MLEM.Data/DynamicEnum.cs +++ b/MLEM.Data/DynamicEnum.cs @@ -148,7 +148,7 @@ namespace MLEM.Data { public static T AddFlag(string name) where T : DynamicEnum { BigInteger value = 0; while (GetStorage(typeof(T)).Values.ContainsKey(value)) - value <<= 1; + value = value != 0 ? value << 1 : 1; return Add(name, value); }