mirror of https://github.com/xemu-project/xemu.git
tests: fix test-vmstate leaks
Spotted thanks to ASAN. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com>
This commit is contained in:
parent
d6f723b513
commit
4ae3c0e27f
|
@ -50,16 +50,20 @@ static QEMUFile *open_test_file(bool write)
|
||||||
{
|
{
|
||||||
int fd = dup(temp_fd);
|
int fd = dup(temp_fd);
|
||||||
QIOChannel *ioc;
|
QIOChannel *ioc;
|
||||||
|
QEMUFile *f;
|
||||||
|
|
||||||
lseek(fd, 0, SEEK_SET);
|
lseek(fd, 0, SEEK_SET);
|
||||||
if (write) {
|
if (write) {
|
||||||
g_assert_cmpint(ftruncate(fd, 0), ==, 0);
|
g_assert_cmpint(ftruncate(fd, 0), ==, 0);
|
||||||
}
|
}
|
||||||
ioc = QIO_CHANNEL(qio_channel_file_new_fd(fd));
|
ioc = QIO_CHANNEL(qio_channel_file_new_fd(fd));
|
||||||
if (write) {
|
if (write) {
|
||||||
return qemu_fopen_channel_output(ioc);
|
f = qemu_fopen_channel_output(ioc);
|
||||||
} else {
|
} else {
|
||||||
return qemu_fopen_channel_input(ioc);
|
f = qemu_fopen_channel_input(ioc);
|
||||||
}
|
}
|
||||||
|
object_unref(OBJECT(ioc));
|
||||||
|
return f;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define SUCCESS(val) \
|
#define SUCCESS(val) \
|
||||||
|
|
Loading…
Reference in New Issue