diff options
Diffstat (limited to 'qemu-char.c')
-rw-r--r-- | qemu-char.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/qemu-char.c b/qemu-char.c index d9100a2201..e6cbafb09c 100644 --- a/qemu-char.c +++ b/qemu-char.c @@ -2481,8 +2481,15 @@ static int tcp_get_msgfds(CharDriverState *chr, int *fds, int num) int to_copy = (s->read_msgfds_num < num) ? s->read_msgfds_num : num; if (to_copy) { + int i; + memcpy(fds, s->read_msgfds, to_copy * sizeof(int)); + /* Close unused fds */ + for (i = to_copy; i < s->read_msgfds_num; i++) { + close(s->read_msgfds[i]); + } + g_free(s->read_msgfds); s->read_msgfds = 0; s->read_msgfds_num = 0; |