Add two asserts to avoid underrunning the seat/device refcount

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
Peter Hutterer 2014-01-08 16:40:14 +10:00 committed by Jonas Ådahl
parent c0ac1ef9f2
commit ded615c64f

View file

@ -504,6 +504,7 @@ libinput_seat_destroy(struct libinput_seat *seat)
LIBINPUT_EXPORT void LIBINPUT_EXPORT void
libinput_seat_unref(struct libinput_seat *seat) libinput_seat_unref(struct libinput_seat *seat)
{ {
assert(seat->refcount > 0);
seat->refcount--; seat->refcount--;
if (seat->refcount == 0) if (seat->refcount == 0)
libinput_seat_destroy(seat); libinput_seat_destroy(seat);
@ -550,6 +551,7 @@ libinput_device_destroy(struct libinput_device *device)
LIBINPUT_EXPORT void LIBINPUT_EXPORT void
libinput_device_unref(struct libinput_device *device) libinput_device_unref(struct libinput_device *device)
{ {
assert(device->refcount > 0);
device->refcount--; device->refcount--;
if (device->refcount == 0) if (device->refcount == 0)
libinput_device_destroy(device); libinput_device_destroy(device);