mirror of
https://github.com/xemu-project/xemu.git
synced 2024-11-27 13:30:52 +00:00
libcacard/vscclient: fix leakage of socket on error paths
Spotted by Coverity. Signed-off-by: Alon Levy <alevy@redhat.com> Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
This commit is contained in:
parent
e098b45386
commit
581fe784c3
@ -618,18 +618,22 @@ connect_to_qemu(
|
||||
if (ret != 0) {
|
||||
/* Error */
|
||||
fprintf(stderr, "getaddrinfo failed\n");
|
||||
return -1;
|
||||
goto cleanup_socket;
|
||||
}
|
||||
|
||||
if (connect(sock, server->ai_addr, server->ai_addrlen) < 0) {
|
||||
/* Error */
|
||||
fprintf(stderr, "Could not connect\n");
|
||||
return -1;
|
||||
goto cleanup_socket;
|
||||
}
|
||||
if (verbose) {
|
||||
printf("Connected (sizeof Header=%zd)!\n", sizeof(VSCMsgHeader));
|
||||
}
|
||||
return sock;
|
||||
|
||||
cleanup_socket:
|
||||
closesocket(sock);
|
||||
return -1;
|
||||
}
|
||||
|
||||
int
|
||||
@ -759,5 +763,6 @@ main(
|
||||
g_io_channel_unref(channel_socket);
|
||||
g_byte_array_unref(socket_to_send);
|
||||
|
||||
closesocket(sock);
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user