Skip to content

Commit c7339c3

Browse files
committed
viewer/svutil: Fix resource leak
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 <sw@weilnetz.de>
1 parent b1f03cb commit c7339c3

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

viewer/svutil.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -422,6 +422,7 @@ SVNetwork::SVNetwork(const char* hostname, int port) {
422422
// Wait for server to show up.
423423
// Note: There is no exception handling in case the server never turns up.
424424

425+
Close();
425426
stream_ = socket(addr_info->ai_family, addr_info->ai_socktype,
426427
addr_info->ai_protocol);
427428

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

438+
Close();
437439
stream_ = socket(addr_info->ai_family, addr_info->ai_socktype,
438440
addr_info->ai_protocol);
439441
}

0 commit comments

Comments
 (0)