Skip to content

Commit

Permalink
test-vmstate: Fix memleaks in test_load_qlist
Browse files Browse the repository at this point in the history
There is memleak in test_load_qlist().It's not a big deal,
but test-vmstate will fail if sanitizers is enabled.

In addition, "ret" is written twice with the same value
 in test_gtree_load_iommu().

Reported-by: Euler Robot <[email protected]>
Signed-off-by: Chen Qun <[email protected]>
Reviewed-by: Juan Quintela <[email protected]>
Reviewed-by: Laurent Vivier <[email protected]>
Signed-off-by: Juan Quintela <[email protected]>
  • Loading branch information
Kuhn-Chen authored and Juan Quintela committed Feb 28, 2020
1 parent 600fe89 commit a6fbd63
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions tests/test-vmstate.c
Original file line number Diff line number Diff line change
Expand Up @@ -1241,7 +1241,6 @@ static void test_gtree_load_iommu(void)
TestGTreeIOMMU *orig_iommu = create_iommu();
QEMUFile *fsave, *fload;
char eof;
int ret;

fsave = open_test_file(true);
qemu_put_buffer(fsave, iommu_dump, sizeof(iommu_dump));
Expand All @@ -1250,10 +1249,8 @@ static void test_gtree_load_iommu(void)

fload = open_test_file(false);
vmstate_load_state(fload, &vmstate_iommu, dest_iommu, 1);
ret = qemu_file_get_error(fload);
eof = qemu_get_byte(fload);
ret = qemu_file_get_error(fload);
g_assert(!ret);
g_assert(!qemu_file_get_error(fload));
g_assert_cmpint(orig_iommu->id, ==, dest_iommu->id);
g_assert_cmpint(eof, ==, QEMU_VM_EOF);

Expand Down Expand Up @@ -1395,6 +1392,7 @@ static void test_load_qlist(void)
compare_containers(orig_container, dest_container);
free_container(orig_container);
free_container(dest_container);
qemu_fclose(fload);
}

typedef struct TmpTestStruct {
Expand Down

0 comments on commit a6fbd63

Please sign in to comment.