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:
parent
26b97f2664
commit
8b2ec54ff3
|
@ -592,19 +592,23 @@ static gboolean tcp_chr_telnet_init_io(QIOChannel *ioc,
|
||||||
ret = 0;
|
ret = 0;
|
||||||
} else {
|
} else {
|
||||||
tcp_chr_disconnect(init->chr);
|
tcp_chr_disconnect(init->chr);
|
||||||
return FALSE;
|
goto end;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
init->buflen -= ret;
|
init->buflen -= ret;
|
||||||
|
|
||||||
if (init->buflen == 0) {
|
if (init->buflen == 0) {
|
||||||
tcp_chr_connect(init->chr);
|
tcp_chr_connect(init->chr);
|
||||||
return FALSE;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
memmove(init->buf, init->buf + ret, init->buflen);
|
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)
|
static void tcp_chr_telnet_init(Chardev *chr)
|
||||||
|
|
Loading…
Reference in New Issue