Fix possible endless loop in replay recorder while opening save file.

This commit is contained in:
Vapre
2021-03-02 21:11:34 +01:00
committed by teinarss
parent 27ddae3df9
commit 52d39db84a

View File

@@ -19,6 +19,9 @@ namespace OpenRA.Network
{
sealed class ReplayRecorder
{
// Arbitrary value.
const int CreateReplayFileMaxRetryCount = 128;
public ReplayMetadata Metadata;
BinaryWriter writer;
Func<string> chooseFilename;
@@ -59,7 +62,12 @@ namespace OpenRA.Network
{
file = File.Create(fullFilename);
}
catch (IOException) { }
catch (IOException ex)
{
if (id > CreateReplayFileMaxRetryCount)
throw new ArgumentException(
"Error creating replay file \"{0}.orarep\"".F(filename), ex);
}
}
file.WriteArray(initialContent);