From 4a28e95ce0bfd3f9064196a503749d7dd8601355 Mon Sep 17 00:00:00 2001 From: arvidn Date: Wed, 13 Jan 2016 00:49:17 -0500 Subject: [PATCH] fix missing error handling in windows preadv/pwritev emulation --- src/file.cpp | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/src/file.cpp b/src/file.cpp index 45e01ab28..773aa9272 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -194,11 +194,19 @@ namespace } } - WaitForMultipleObjects(num_bufs, h, TRUE, INFINITE); + if (WaitForMultipleObjects(num_bufs, h, TRUE, INFINITE) == WAIT_FAILED) + { + ret = -1; + break; + } for (int i = 0; i < num_bufs; ++i) { - WaitForSingleObject(ol[i].hEvent, INFINITE); + if (WaitForSingleObject(ol[i].hEvent, INFINITE) == WAIT_FAILED) + { + ret = -1; + break; + } DWORD num_read; if (GetOverlappedResult(fd, &ol[i], &num_read, FALSE) == FALSE) { @@ -256,11 +264,19 @@ done: } } - WaitForMultipleObjects(num_bufs, h, TRUE, INFINITE); + if (WaitForMultipleObjects(num_bufs, h, TRUE, INFINITE) == WAIT_FAILED) + { + ret = -1; + break; + } for (int i = 0; i < num_bufs; ++i) { - WaitForSingleObject(ol[i].hEvent, INFINITE); + if (WaitForSingleObject(ol[i].hEvent, INFINITE) == WAIT_FAILED) + { + ret = -1; + break; + } DWORD num_written; if (GetOverlappedResult(fd, &ol[i], &num_written, FALSE) == FALSE) {