Commit c5c6320f authored by Sonny Sasaka's avatar Sonny Sasaka Committed by Commit Bot

chrome.bluetoothSocket: Fix regression in send()

In https://crrev.com/c/997098, params_ was changed to a local variable,
but it needs to last longer than that since net::WrappedIOBuffer may use
the data after the local variable goes out of scope.

This CL changed it back to be an instance variable.

Bug: 851799
Change-Id: I392f8acaef4c6473d6ea4fbee7209445aa09112e
Reviewed-on: https://chromium-review.googlesource.com/1103676Reviewed-by: default avatarToni Barzic <tbarzic@chromium.org>
Commit-Queue: Sonny Sasaka <sonnysasaka@chromium.org>
Cr-Commit-Position: refs/heads/master@{#568137}
parent 9e0b47c5
...@@ -545,13 +545,13 @@ BluetoothSocketSendFunction::~BluetoothSocketSendFunction() {} ...@@ -545,13 +545,13 @@ BluetoothSocketSendFunction::~BluetoothSocketSendFunction() {}
ExtensionFunction::ResponseAction BluetoothSocketSendFunction::Run() { ExtensionFunction::ResponseAction BluetoothSocketSendFunction::Run() {
DCHECK_CURRENTLY_ON(work_thread_id()); DCHECK_CURRENTLY_ON(work_thread_id());
auto params = bluetooth_socket::Send::Params::Create(*args_); params_ = bluetooth_socket::Send::Params::Create(*args_);
EXTENSION_FUNCTION_VALIDATE(params.get()); EXTENSION_FUNCTION_VALIDATE(params_.get());
io_buffer_size_ = params->data.size(); io_buffer_size_ = params_->data.size();
io_buffer_ = new net::WrappedIOBuffer(params->data.data()); io_buffer_ = new net::WrappedIOBuffer(params_->data.data());
BluetoothApiSocket* socket = GetSocket(params->socket_id); BluetoothApiSocket* socket = GetSocket(params_->socket_id);
if (!socket) if (!socket)
return RespondNow(Error(kSocketNotFoundError)); return RespondNow(Error(kSocketNotFoundError));
......
...@@ -294,6 +294,7 @@ class BluetoothSocketSendFunction : public BluetoothSocketAsyncApiFunction { ...@@ -294,6 +294,7 @@ class BluetoothSocketSendFunction : public BluetoothSocketAsyncApiFunction {
void OnError(BluetoothApiSocket::ErrorReason reason, void OnError(BluetoothApiSocket::ErrorReason reason,
const std::string& message); const std::string& message);
std::unique_ptr<bluetooth_socket::Send::Params> params_;
scoped_refptr<net::IOBuffer> io_buffer_; scoped_refptr<net::IOBuffer> io_buffer_;
size_t io_buffer_size_; size_t io_buffer_size_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment