Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1906)

Unified Diff: net/base/file_stream_context_win.cc

Issue 920123002: Fix a crash in the FileStream::Context::Read code path where we were invoking a NULL callback. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address review comments Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/base/file_stream_context.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/base/file_stream_context_win.cc
diff --git a/net/base/file_stream_context_win.cc b/net/base/file_stream_context_win.cc
index 5ffbde72388293a339e46430846f4be6df62695c..e6c1b528bc09cf130054ebcd71118283716c24cc 100644
--- a/net/base/file_stream_context_win.cc
+++ b/net/base/file_stream_context_win.cc
@@ -174,6 +174,8 @@ void FileStream::Context::OnIOCompleted(
}
void FileStream::Context::InvokeUserCallback() {
+ if (callback_.is_null())
+ return;
// For an asynchonous Read operation don't invoke the user callback until
// we receive the IO completion notification and the asynchronous Read
// completion notification.
@@ -203,15 +205,18 @@ void FileStream::Context::ReadAsync(
DWORD bytes_read = 0;
BOOL ret = ::ReadFile(file, buf->data(), buf_len, &bytes_read, overlapped);
origin_thread_loop->PostTask(
- FROM_HERE, base::Bind(&FileStream::Context::ReadAsyncResult,
- base::Unretained(context), ret ? bytes_read : 0,
- ret ? 0 : ::GetLastError()));
+ FROM_HERE,
+ base::Bind(&FileStream::Context::ReadAsyncResult,
+ base::Unretained(context), ret, bytes_read, ::GetLastError()));
}
-void FileStream::Context::ReadAsyncResult(DWORD bytes_read, DWORD os_error) {
- if (!os_error)
+void FileStream::Context::ReadAsyncResult(BOOL read_file_ret,
+ DWORD bytes_read,
+ DWORD os_error) {
+ if (read_file_ret) {
rvargas (doing something else) 2015/02/12 23:53:35 Note that the original logic was: DWORD byt
ananta 2015/02/13 00:17:00 Did something similar.
+ DCHECK(!os_error);
result_ = bytes_read;
-
+ }
IOResult error = IOResult::FromOSError(os_error);
if (error.os_error == ERROR_HANDLE_EOF) {
// Report EOF by returning 0 bytes read.
« no previous file with comments | « net/base/file_stream_context.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698