Skip to content

Commit

Permalink
SVNetwork: Handle failed socket call (CID 1164597)
Browse files Browse the repository at this point in the history
This fixes a warning from Coverity Scan.

Signed-off-by: Stefan Weil <[email protected]>
  • Loading branch information
stweil committed Oct 16, 2018
1 parent 2d2b269 commit 5fb461a
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/viewer/svutil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -401,8 +401,10 @@ SVNetwork::SVNetwork(const char* hostname, int port) {
stream_ = socket(addr_info->ai_family, addr_info->ai_socktype,
addr_info->ai_protocol);

// If server is not there, we will start a new server as local child process.
if (connect(stream_, addr_info->ai_addr, addr_info->ai_addrlen) < 0) {
if (stream_ < 0) {
std::cerr << "Failed to open socket" << std::endl;
} else if (connect(stream_, addr_info->ai_addr, addr_info->ai_addrlen) < 0) {
// If server is not there, we will start a new server as local child process.
const char* scrollview_path = getenv("SCROLLVIEW_PATH");
if (scrollview_path == nullptr) {
#ifdef SCROLLVIEW_PATH
Expand Down

0 comments on commit 5fb461a

Please sign in to comment.