From 70c17eac019a3801f3e748d9366e5d2b4fbca9b8 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Wed, 26 Jun 2013 16:47:43 +1000 Subject: [PATCH] Don't crash peeking at a zero-sized queue Signed-off-by: Peter Hutterer --- libevdev/libevdev-int.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libevdev/libevdev-int.h b/libevdev/libevdev-int.h index 5d3502a..1a4f224 100644 --- a/libevdev/libevdev-int.h +++ b/libevdev/libevdev-int.h @@ -121,7 +121,7 @@ queue_pop(struct libevdev *dev, struct input_event *ev) static inline int queue_peek(struct libevdev *dev, size_t idx, struct input_event *ev) { - if (idx > dev->queue_next) + if (dev->queue_next == 0 || idx > dev->queue_next) return 1; *ev = dev->queue[idx]; return 0; -- 2.7.4