chardev: fix leak in tcp_chr_telnet_init_io()

Need to free TCPChardevTelnetInit when session established.

Since at it, switch to use G_SOURCE_* macros.

Reviewed-by: Daniel P. Berrange <berrange@redhat.com>
Signed-off-by: Peter Xu <peterx@redhat.com>
Message-Id: <20180301084438.13594-2-peterx@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
Peter Xu 2018-03-01 16:44:24 +08:00 committed by Paolo Bonzini
parent 26b97f2664
commit 8b2ec54ff3

View File

@ -592,19 +592,23 @@ static gboolean tcp_chr_telnet_init_io(QIOChannel *ioc,
ret = 0;
} else {
tcp_chr_disconnect(init->chr);
return FALSE;
goto end;
}
}
init->buflen -= ret;
if (init->buflen == 0) {
tcp_chr_connect(init->chr);
return FALSE;
goto end;
}
memmove(init->buf, init->buf + ret, init->buflen);
return TRUE;
return G_SOURCE_CONTINUE;
end:
g_free(init);
return G_SOURCE_REMOVE;
}
static void tcp_chr_telnet_init(Chardev *chr)