test: unref the litest device *after* removing it from the path interface
authorPeter Hutterer <peter.hutterer@who-t.net>
Tue, 17 Oct 2017 06:55:27 +0000 (16:55 +1000)
committerPeter Hutterer <peter.hutterer@who-t.net>
Tue, 17 Oct 2017 06:55:27 +0000 (16:55 +1000)
Our own reference may be the last one that's still alive if the context is
currently suspended (litest_suspend()). If we unref before removing it from
the path interface, we access already freed memory.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Jonas Ã…dahl <jadahl@gmail.com>
test/litest.c

index 4f26771f78f51192093c85bd34e3a64c99e8468f..d34bd3c52383b8832eb65174bda32b2f70cdc728 100644 (file)
@@ -1341,8 +1341,8 @@ litest_delete_device(struct litest_device *d)
        litest_assert_int_eq(d->skip_ev_syn, 0);
 
        if (d->libinput_device) {
-               libinput_device_unref(d->libinput_device);
                libinput_path_remove_device(d->libinput_device);
+               libinput_device_unref(d->libinput_device);
        }
        if (d->owns_context)
                libinput_unref(d->libinput);