Skip to content

Commit

Permalink
[M70]Fix audio::InputIPC crash.
Browse files Browse the repository at this point in the history
StreamCreated() may be called after CloseStream(), leading to a null
pointer deref on |delegate_|. Avoid this by invalidating the
weak pointer that was bound into StreamCreated().

Bug: 879257
Change-Id: I954421b384928bff3c3d17506850012e2a1da1b3
Reviewed-on: https://chromium-review.googlesource.com/1199142
Commit-Queue: Olga Sharonova <olka@chromium.org>
Reviewed-by: Olga Sharonova <olka@chromium.org>
Cr-Original-Commit-Position: refs/heads/master@{#587981}(cherry picked from commit 4ef85aa)
Reviewed-on: https://chromium-review.googlesource.com/1202042
Reviewed-by: Max Morin <maxmorin@chromium.org>
Cr-Commit-Position: refs/branch-heads/3538@{#13}
Cr-Branched-From: 79f7c91-refs/heads/master@{#587811}
  • Loading branch information
Max Morin committed Sep 3, 2018
1 parent 513c8ff commit 03ff085
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
3 changes: 3 additions & 0 deletions services/audio/public/cpp/input_ipc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,9 @@ void InputIPC::CloseStream() {
if (stream_client_binding_.is_bound())
stream_client_binding_.Close();
stream_.reset();

// Make sure we don't get any stale stream creation messages.
weak_factory_.InvalidateWeakPtrs();
}

void InputIPC::OnError() {
Expand Down
7 changes: 7 additions & 0 deletions services/audio/public/cpp/input_ipc_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,13 @@ TEST_F(InputIPCTest, CreateStreamPropagates) {
scoped_task_environment.RunUntilIdle();
}

TEST_F(InputIPCTest, StreamCreatedAfterCloseIsIgnored) {
StrictMock<MockDelegate> delegate;
ipc->CreateStream(&delegate, audioParameters, false, 0);
ipc->CloseStream();
scoped_task_environment.RunUntilIdle();
}

TEST_F(InputIPCTest, CreateStreamPropagatesInitiallyMuted) {
StrictMock<MockDelegate> delegate;

Expand Down

0 comments on commit 03ff085

Please sign in to comment.