Skip to content

Commit ea23296

Browse files
committed
refactor(runtime/{bridge,webview}): more safety checks
1 parent d4386b1 commit ea23296

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

src/runtime/bridge/bridge.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -482,8 +482,8 @@ export * from '{{url}}'
482482

483483
const auto app = App::sharedApplication();
484484
const auto options = serviceworker::Fetch::Options { request->client };
485-
const auto fetched = serviceWorker->fetch(fetch, options, [=, this, &request] (auto res) mutable {
486-
if (!request->isActive()) {
485+
const auto fetched = serviceWorker->fetch(fetch, options, [=, this] (auto res) mutable {
486+
if (!request || !request->isActive()) {
487487
return;
488488
}
489489

@@ -592,7 +592,7 @@ export * from '{{url}}'
592592
});
593593

594594
if (fetched) {
595-
this->getRuntime()->services.timers.setTimeout(32000, [&request] () mutable {
595+
this->getRuntime()->services.timers.setTimeout(32000, [request] () mutable {
596596
if (request->isActive()) {
597597
auto response = SchemeHandlers::Response(request, 408);
598598
response.fail("ServiceWorker request timed out.");

src/runtime/webview/scheme_handlers.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -936,6 +936,9 @@ namespace ssc::runtime::webview {
936936

937937
bool SchemeHandlers::Request::isActive () const {
938938
auto app = app::App::sharedApplication();
939+
if (this->handlers == nullptr) {
940+
return false;
941+
}
939942
auto window = app->runtime.windowManager.getWindowForBridge(&this->handlers->bridge);
940943

941944
// only a scheme handler owned by this bridge and attached to a

0 commit comments

Comments
 (0)