From 901c14c409e6e8143ade06a7478241e558cfb79c Mon Sep 17 00:00:00 2001 From: Calvin Lee Date: Wed, 16 Aug 2017 09:23:21 +0200 Subject: Prevent alloc errors from crashing in `list_t` This commit changes the `list_t` api so that alloc errors can be detected and worked around. Also fixes errors not found in 5cc7342 --- examples/touch.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'examples') diff --git a/examples/touch.c b/examples/touch.c index a32c76ba..7e01a6c2 100644 --- a/examples/touch.c +++ b/examples/touch.c @@ -65,7 +65,9 @@ static void handle_touch_down(struct touch_state *tstate, int32_t slot, point->slot = slot; point->x = x / width; point->y = y / height; - list_add(sample->touch_points, point); + if (list_add(sample->touch_points, point) == -1) { + free(point); + } } static void handle_touch_up(struct touch_state *tstate, int32_t slot) { -- cgit v1.2.3