Skip to content

Commit

Permalink
viewer/svutil: Fix resource leak
Browse files Browse the repository at this point in the history
Coverity report:

CID 1164526 (#1 of 1): Resource leak in object (CTOR_DTOR_LEAK)
2. alloc_fn: Calling allocation function socket.

The previous stream_ must be closed before opening a new one.

Signed-off-by: Stefan Weil <[email protected]>
  • Loading branch information
stweil committed Oct 24, 2016
1 parent b1f03cb commit c7339c3
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions viewer/svutil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,7 @@ SVNetwork::SVNetwork(const char* hostname, int port) {
// Wait for server to show up.
// Note: There is no exception handling in case the server never turns up.

Close();
stream_ = socket(addr_info->ai_family, addr_info->ai_socktype,
addr_info->ai_protocol);

Expand All @@ -434,6 +435,7 @@ SVNetwork::SVNetwork(const char* hostname, int port) {
sleep(1);
#endif

Close();
stream_ = socket(addr_info->ai_family, addr_info->ai_socktype,
addr_info->ai_protocol);
}
Expand Down

0 comments on commit c7339c3

Please sign in to comment.