diff --git a/src/file.cpp b/src/file.cpp index ebcc16e1e..2b5670cdc 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -1344,7 +1344,12 @@ namespace libtorrent CloseHandle(ol.hEvent); return -1; } - WaitForSingleObject(ol.hEvent, INFINITE); + if (WaitForSingleObject(ol.hEvent, INFINITE) == WAIT_FAILED) + { + ec.assign(GetLastError(), get_system_category()); + CloseHandle(ol.hEvent); + return -1; + } DWORD num_read; if (GetOverlappedResult(m_file_handle, &ol, &num_read, false) == 0) { @@ -1584,7 +1589,12 @@ namespace libtorrent CloseHandle(ol.hEvent); return -1; } - WaitForSingleObject(ol.hEvent, INFINITE); + if (WaitForSingleObject(ol.hEvent, INFINITE) == WAIT_FAILED) + { + ec.assign(GetLastError(), get_system_category()); + CloseHandle(ol.hEvent); + return -1; + } DWORD num_written; if (GetOverlappedResult(m_file_handle, &ol, &num_written, false) == 0) {