Browse Source

Fixed possible race condition

ManlyMarco 4 years ago
parent
commit
d0b529166d
1 changed files with 6 additions and 6 deletions
  1. 6 6
      BepInEx/Configuration/ConfigFile.cs

+ 6 - 6
BepInEx/Configuration/ConfigFile.cs

@@ -205,9 +205,9 @@ namespace BepInEx.Configuration
 			if (!TomlTypeConverter.CanConvert(typeof(T)))
 				throw new ArgumentException($"Type {typeof(T)} is not supported by the config system. Supported types: {string.Join(", ", TomlTypeConverter.GetSupportedTypes().Select(x => x.Name).ToArray())}");
 
-			try
+			lock (_ioLock)
 			{
-				lock (_ioLock)
+				try
 				{
 					_disableSaving = true;
 
@@ -244,10 +244,10 @@ namespace BepInEx.Configuration
 
 					return entry;
 				}
-			}
-			finally
-			{
-				_disableSaving = false;
+				finally
+				{
+					_disableSaving = false;
+				}
 			}
 		}