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

Unified Diff: device/serial/serial_io_handler.cc

Issue 551713002: Fix a crash in SerialIoHandler. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: device/serial/serial_io_handler.cc
diff --git a/device/serial/serial_io_handler.cc b/device/serial/serial_io_handler.cc
index eb55e414e0053bd81354f619101fa52c1d62c0c3..ee6fab3095c6f60b1483df557376f77e42002391 100644
--- a/device/serial/serial_io_handler.cc
+++ b/device/serial/serial_io_handler.cc
@@ -114,12 +114,12 @@ void SerialIoHandler::ReadCompleted(int bytes_read,
serial::ReceiveError error) {
DCHECK(CalledOnValidThread());
DCHECK(IsReadPending());
+ scoped_ptr<WritableBuffer> pending_read_buffer = pending_read_buffer_.Pass();
if (error == serial::RECEIVE_ERROR_NONE) {
- pending_read_buffer_->Done(bytes_read);
+ pending_read_buffer->Done(bytes_read);
} else {
- pending_read_buffer_->DoneWithError(bytes_read, error);
+ pending_read_buffer->DoneWithError(bytes_read, error);
}
- pending_read_buffer_.reset();
Release();
}
@@ -127,12 +127,13 @@ void SerialIoHandler::WriteCompleted(int bytes_written,
serial::SendError error) {
DCHECK(CalledOnValidThread());
DCHECK(IsWritePending());
+ scoped_ptr<ReadOnlyBuffer> pending_write_buffer =
+ pending_write_buffer_.Pass();
if (error == serial::SEND_ERROR_NONE) {
- pending_write_buffer_->Done(bytes_written);
+ pending_write_buffer->Done(bytes_written);
} else {
- pending_write_buffer_->DoneWithError(bytes_written, error);
+ pending_write_buffer->DoneWithError(bytes_written, error);
}
- pending_write_buffer_.reset();
Release();
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698