Browse Source

CloseHandle: Avoid double lookup of file

pull/534/head
Gleb Mazovetskiy 6 years ago committed by Anders Jenbo
parent
commit
e1b0712f74
  1. 5
      SourceX/miniwin/misc_io.cpp

5
SourceX/miniwin/misc_io.cpp

@ -115,11 +115,12 @@ void ShowOutOfDiskError()
WINBOOL CloseHandle(HANDLE hObject)
{
memfile *file = static_cast<memfile *>(hObject);
if (files.find(file) == files.end())
const auto file_it = files.find(file);
if (file_it == files.end())
return CloseEvent(hObject);
std::unique_ptr<memfile> ufile(file); // ensure that delete file is
// called on returning
files.erase(file);
files.erase(file_it);
std::ofstream filestream(file->path + ".tmp", std::ios::binary | std::ios::trunc);
if (filestream.fail()) {
ShowOutOfDiskError();

Loading…
Cancel
Save