From e636c1b44d1c18ef00bebeb0f8caa15e7f75b21d Mon Sep 17 00:00:00 2001 From: Chase Latta Date: Tue, 12 Jan 2021 13:14:02 -0800 Subject: [PATCH] [dart-runner] Avoid calling Destroy on nullptr (flutter/engine#23608) --- .../fuchsia/dart_runner/dart_component_controller.cc | 6 +++++- .../shell/platform/fuchsia/dart_runner/dart_runner.cc | 7 ++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/engine/src/flutter/shell/platform/fuchsia/dart_runner/dart_component_controller.cc b/engine/src/flutter/shell/platform/fuchsia/dart_runner/dart_component_controller.cc index 3680a875d1..dd9b16bd65 100644 --- a/engine/src/flutter/shell/platform/fuchsia/dart_runner/dart_component_controller.cc +++ b/engine/src/flutter/shell/platform/fuchsia/dart_runner/dart_component_controller.cc @@ -440,7 +440,11 @@ bool DartComponentController::Main() { void DartComponentController::Kill() { if (Dart_CurrentIsolate()) { - tonic::DartMicrotaskQueue::GetForCurrentThread()->Destroy(); + tonic::DartMicrotaskQueue* queue = + tonic::DartMicrotaskQueue::GetForCurrentThread(); + if (queue) { + queue->Destroy(); + } loop_->Quit(); diff --git a/engine/src/flutter/shell/platform/fuchsia/dart_runner/dart_runner.cc b/engine/src/flutter/shell/platform/fuchsia/dart_runner/dart_runner.cc index 415d2885c6..2a87776cb4 100644 --- a/engine/src/flutter/shell/platform/fuchsia/dart_runner/dart_runner.cc +++ b/engine/src/flutter/shell/platform/fuchsia/dart_runner/dart_runner.cc @@ -83,7 +83,12 @@ void IsolateShutdownCallback(void* isolate_group_data, void* isolate_data) { auto dispatcher = async_get_default_dispatcher(); auto loop = async_loop_from_dispatcher(dispatcher); if (loop) { - tonic::DartMicrotaskQueue::GetForCurrentThread()->Destroy(); + tonic::DartMicrotaskQueue* queue = + tonic::DartMicrotaskQueue::GetForCurrentThread(); + if (queue) { + queue->Destroy(); + } + async_loop_quit(loop); }