Skip to content

Commit

Permalink
Catch potential nullptr in SVNetwork::SVNetwork
Browse files Browse the repository at this point in the history
Signed-off-by: Stefan Weil <[email protected]>
  • Loading branch information
stweil committed Jul 18, 2022
1 parent 87dd04f commit 02e8340
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/viewer/svutil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -297,8 +297,13 @@ SVNetwork::SVNetwork(const char *hostname, int port) {
# endif // _WIN32
}

stream_ = socket(addr_info->ai_family, addr_info->ai_socktype,
addr_info->ai_protocol);
if (addr_info == nullptr) {
// Mark stream_ as invalid.
stream_ = -1;
} else {
stream_ = socket(addr_info->ai_family, addr_info->ai_socktype,
addr_info->ai_protocol);
}

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

0 comments on commit 02e8340

Please sign in to comment.