From 95ef1c9529c0e1f9a1554be2a61e76beb51aedbd Mon Sep 17 00:00:00 2001 From: Alex Barney Date: Sun, 22 Mar 2020 17:52:27 -0700 Subject: [PATCH] Don't write to a read-only file --- src/LibHac/FsService/Impl/MultiCommitManager.cs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/LibHac/FsService/Impl/MultiCommitManager.cs b/src/LibHac/FsService/Impl/MultiCommitManager.cs index 66361e15..e8a0a31b 100644 --- a/src/LibHac/FsService/Impl/MultiCommitManager.cs +++ b/src/LibHac/FsService/Impl/MultiCommitManager.cs @@ -190,6 +190,16 @@ namespace LibHac.FsService.Impl rc = _fileSystem.OpenFile(out contextFile, ContextFileName, OpenMode.Read); if (rc.IsFailure()) return rc; } + } + finally + { + contextFile?.Dispose(); + } + + try + { + Result rc = _fileSystem.OpenFile(out contextFile, ContextFileName, OpenMode.ReadWrite); + if (rc.IsFailure()) return rc; _context.Version = CurrentContextVersion; _context.State = CommitState.NotCommitted;