From 03cb196115a839c5dab6e2dd6451940ddc8797ab Mon Sep 17 00:00:00 2001 From: huanghan18 Date: Thu, 17 Apr 2025 15:04:53 +0800 Subject: [PATCH] codecheck:add nullptr check Signed-off-by: huanghan18 --- src/inspector/inspector_socket_server.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/inspector/inspector_socket_server.cpp b/src/inspector/inspector_socket_server.cpp index 893fcf3..82a440c 100644 --- a/src/inspector/inspector_socket_server.cpp +++ b/src/inspector/inspector_socket_server.cpp @@ -12,7 +12,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - #include "inspector_socket_server.h" #include @@ -25,6 +24,7 @@ #include #include +#include "jsvm_dfx.h" #include "jsvm_version.h" #include "uv.h" #include "v8_inspector_protocol_json.h" @@ -327,6 +327,7 @@ SocketSession* InspectorSocketServer::Session(int sessionId) void InspectorSocketServer::SessionStarted(int sessionId, const std::string& targetId, const std::string& wsKey) { SocketSession* session = Session(sessionId); + CHECK_NULL(session); if (!TargetExists(targetId)) { session->Decline(); return; @@ -360,6 +361,7 @@ void InspectorSocketServer::SessionTerminated(int sessionId) bool InspectorSocketServer::HandleGetRequest(int sessionId, const std::string& hostName, const std::string& path) { SocketSession* session = Session(sessionId); + CHECK_NULL(session); InspectorSocket* socket = session->GetWsSocket(); if (!inspectPublishUid.http) { SendHttpNotFound(socket); @@ -550,7 +552,9 @@ void SocketSession::Send(const std::string& message) void SocketSession::Delegate::OnHttpGet(const std::string& host, const std::string& path) { if (!server->HandleGetRequest(usessionId, host, path)) { - Session()->GetWsSocket()->CancelHandshake(); + SocketSession* session = Session(); + CHECK_NULL(session); + session->GetWsSocket()->CancelHandshake(); } } -- Gitee