Skip to content

Commit e1d58ec

Browse files
RovicnowYoyipopoaichuiniu
authored andcommitted
[BugFix]Fix that current_transceiver_ maybe nullptr
When the OnOpen function is not used to assign a value to current_transceiver_, nullptr will cause current_transceiver_->GetType() to crash.
1 parent fd1246a commit e1d58ec

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

debug_router/native/core/debug_router_core.cc

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -403,15 +403,23 @@ void DebugRouterCore::OnFailure(
403403
connection_state_.load(std::memory_order_relaxed) == DISCONNECTED) {
404404
return;
405405
}
406-
if (current_transceiver_->GetType() == ConnectionType::kUsb) {
407-
Json::Value catagaryJson;
408-
catagaryJson["connect_type"] = "usb";
409-
catagaryJson["error_msg"] = error_message;
410-
std::string catagary = catagaryJson.toStyledString();
411-
Report("OnFailure", catagary, "", "");
406+
if (current_transceiver_ != nullptr) {
407+
if (current_transceiver_->GetType() == ConnectionType::kUsb) {
408+
Json::Value catagaryJson;
409+
catagaryJson["connect_type"] = "usb";
410+
catagaryJson["error_msg"] = error_message;
411+
std::string catagary = catagaryJson.toStyledString();
412+
Report("OnFailure", catagary, "", "");
413+
} else {
414+
Json::Value catagaryJson;
415+
catagaryJson["connect_type"] = "websocket";
416+
catagaryJson["error_msg"] = error_message;
417+
std::string catagary = catagaryJson.toStyledString();
418+
Report("OnFailure", catagary, "", "");
419+
}
412420
} else {
413421
Json::Value catagaryJson;
414-
catagaryJson["connect_type"] = "websocket";
422+
catagaryJson["connect_type"] = "none";
415423
catagaryJson["error_msg"] = error_message;
416424
std::string catagary = catagaryJson.toStyledString();
417425
Report("OnFailure", catagary, "", "");

0 commit comments

Comments
 (0)