Skip to content

Commit 5fb461a

Browse files
committed
SVNetwork: Handle failed socket call (CID 1164597)
This fixes a warning from Coverity Scan. Signed-off-by: Stefan Weil <[email protected]>
1 parent 2d2b269 commit 5fb461a

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/viewer/svutil.cpp

+4-2
Original file line numberDiff line numberDiff line change
@@ -401,8 +401,10 @@ SVNetwork::SVNetwork(const char* hostname, int port) {
401401
stream_ = socket(addr_info->ai_family, addr_info->ai_socktype,
402402
addr_info->ai_protocol);
403403

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

0 commit comments

Comments
 (0)