Skip to content

Commit 0e915c2

Browse files
RovicnowYoyipopoaichuiniu
authored andcommitted
[BugFix]Fix crash that socket_guard_ maybe nullptr
If the connect function has not succeeded, socket_guard_ may still be nullptr, and socket_guard_.Get() will cause the crash.
1 parent 99358e9 commit 0e915c2

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

debug_router/native/net/websocket_task.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,10 @@ bool WebSocketTask::do_connect() {
190190
}
191191
CLOSESOCKET(sockfd);
192192
}
193+
if (socket_guard_ == nullptr) {
194+
LOGE("Connect " << url_.c_str() << "Error: socket_guard_ is nullptr.");
195+
return false;
196+
}
193197
freeaddrinfo(servinfo);
194198

195199
char buf[512];

0 commit comments

Comments
 (0)