Skip to content

Commit 02e8340

Browse files
committed
Catch potential nullptr in SVNetwork::SVNetwork
Signed-off-by: Stefan Weil <[email protected]>
1 parent 87dd04f commit 02e8340

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/viewer/svutil.cpp

+7-2
Original file line numberDiff line numberDiff line change
@@ -297,8 +297,13 @@ SVNetwork::SVNetwork(const char *hostname, int port) {
297297
# endif // _WIN32
298298
}
299299

300-
stream_ = socket(addr_info->ai_family, addr_info->ai_socktype,
301-
addr_info->ai_protocol);
300+
if (addr_info == nullptr) {
301+
// Mark stream_ as invalid.
302+
stream_ = -1;
303+
} else {
304+
stream_ = socket(addr_info->ai_family, addr_info->ai_socktype,
305+
addr_info->ai_protocol);
306+
}
302307

303308
if (stream_ < 0) {
304309
std::cerr << "Failed to open socket" << std::endl;

0 commit comments

Comments
 (0)