From e6d7700746c65a0dbae0cd2ebbd009776fdce035 Mon Sep 17 00:00:00 2001 From: JC Yang Date: Mon, 5 Aug 2024 12:28:17 -0400 Subject: [PATCH] Fix dangling ptr in ReadResponseCallbackWrapper (fixes #3760) --- .../browser/net_service/stream_reader_url_loader.cc | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/libcef/browser/net_service/stream_reader_url_loader.cc b/libcef/browser/net_service/stream_reader_url_loader.cc index 77650d8b5..d583df467 100644 --- a/libcef/browser/net_service/stream_reader_url_loader.cc +++ b/libcef/browser/net_service/stream_reader_url_loader.cc @@ -213,7 +213,8 @@ class InputStreamReader : public base::RefCountedThreadSafe { InputStream::SkipCallback skip_callback); static void RunReadCallbackOnJobThread( int bytes_read, - InputStream::ReadCallback read_callback); + InputStream::ReadCallback read_callback, + scoped_refptr buffer); std::unique_ptr stream_; @@ -442,8 +443,9 @@ void InputStreamReader::RunReadCallback(int bytes_read) { DCHECK(!pending_read_callback_.is_null()); job_thread_task_runner_->PostTask( - FROM_HERE, base::BindOnce(InputStreamReader::RunReadCallbackOnJobThread, - bytes_read, std::move(pending_read_callback_))); + FROM_HERE, + base::BindOnce(InputStreamReader::RunReadCallbackOnJobThread, bytes_read, + std::move(pending_read_callback_), buffer_)); // Reset callback state. pending_callback_id_ = -1; @@ -460,7 +462,8 @@ void InputStreamReader::RunSkipCallbackOnJobThread( // static void InputStreamReader::RunReadCallbackOnJobThread( int bytes_read, - InputStream::ReadCallback read_callback) { + InputStream::ReadCallback read_callback, + scoped_refptr buffer) { std::move(read_callback).Run(bytes_read); }