From d546cafda446a73206b5a862c614fc96c732bd7c Mon Sep 17 00:00:00 2001 From: shenleban tongying Date: Tue, 19 Mar 2024 03:18:21 -0400 Subject: [PATCH] fix: a crash when qrcx:// fails. The reply here might be nullptr. --- src/resourceschemehandler.cc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/resourceschemehandler.cc b/src/resourceschemehandler.cc index a4cd2ec6..8aaad1b9 100644 --- a/src/resourceschemehandler.cc +++ b/src/resourceschemehandler.cc @@ -12,7 +12,12 @@ void ResourceSchemeHandler::requestStarted( QWebEngineUrlRequestJob * requestJob const QMimeType mineType = db.mimeTypeForUrl( url ); const sptr< Dictionary::DataRequest > reply = this->mManager.getResource( url, content_type ); content_type = mineType.name(); - if ( reply->isFinished() ) { + + if ( reply == nullptr ) { + qDebug() << "Resource failed to load: " << url.toString(); + requestJob->fail( QWebEngineUrlRequestJob::RequestFailed ); + } + else if ( reply->isFinished() ) { replyJob( reply, requestJob, content_type ); } else