diff options
author | Calvin Lee <cyrus296@gmail.com> | 2017-08-16 09:23:21 +0200 |
---|---|---|
committer | Calvin Lee <cyrus296@gmail.com> | 2017-08-16 09:23:21 +0200 |
commit | 901c14c409e6e8143ade06a7478241e558cfb79c (patch) | |
tree | 8e83344aeadb70c3449baa663d02d7013c542d62 /examples | |
parent | 19d6442f52743d50d10c796d7146f58c251f67fe (diff) |
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
Diffstat (limited to 'examples')
-rw-r--r-- | examples/touch.c | 4 |
1 files changed, 3 insertions, 1 deletions
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) { |