libqtest: fix memory leak in the qtest_qmp_event_ref
commitd232b87ec6e3a8a04db9b647f61a1e3a6855a58f
authorMaxim Levitsky <mlevitsk@redhat.com>
Mon, 19 Oct 2020 16:37:01 +0000 (19 19:37 +0300)
committerThomas Huth <thuth@redhat.com>
Sat, 24 Oct 2020 05:36:53 +0000 (24 07:36 +0200)
tree900e1bc191f4fb1700708a2731e923b2a935a487
parent7f9d519c0d37b8af0b228a4ed49d33ea095e9eb7
libqtest: fix memory leak in the qtest_qmp_event_ref

The g_list_remove_link doesn't free the link element,
opposed to what I thought.
Switch to g_list_delete_link that does free it.

Also refactor the code a bit.
Thanks for Max Reitz for helping me with this.

Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com>
Message-Id: <20201019163702.471239-4-mlevitsk@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
tests/qtest/libqtest.c