Commit 5bbebf62 authored by zhanghailiang's avatar zhanghailiang Committed by Paolo Bonzini

libcacard: fix resource leak

In function connect_to_qemu(), getaddrinfo() will allocate memory
that is stored into server, it should be freed by using freeaddrinfo()
before connect_to_qemu() return.

Reviewed-by: default avatarMarkus Armbruster <>
Signed-off-by: default avatarzhanghailiang <>
Signed-off-by: default avatarPaolo Bonzini <>
parent c52e6792
......@@ -597,7 +597,7 @@ connect_to_qemu(
const char *port
) {
struct addrinfo hints;
struct addrinfo *server;
struct addrinfo *server = NULL;
int ret, sock;
sock = socket(AF_INET, SOCK_STREAM, 0);
......@@ -629,9 +629,14 @@ connect_to_qemu(
if (verbose) {
printf("Connected (sizeof Header=%zd)!\n", sizeof(VSCMsgHeader));
return sock;
if (server) {
return -1;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment