diff --git a/cef1/tests/cefclient/download_handler.cpp b/cef1/tests/cefclient/download_handler.cpp index ae5c9c9d0..d7f02a43f 100644 --- a/cef1/tests/cefclient/download_handler.cpp +++ b/cef1/tests/cefclient/download_handler.cpp @@ -180,8 +180,16 @@ class ClientDownloadHandler : public CefDownloadHandler { std::vector*>::iterator it = data.begin(); for (; it != data.end(); ++it) { std::vector* buffer = *it; - if (file_) - fwrite(&(*buffer)[0], buffer->size(), 1, file_); + if (file_) { + size_t total = 0; + do { + size_t write = + fwrite(&(*buffer)[total], 1, buffer->size() - total, file_); + if (write == 0) + break; + total += write; + } while (total < buffer->size()); + } delete buffer; } data.clear();