[PATCH libinput] evdev-mt-touchpad: check calloc result
Carlos Olmedo Escobar
carlos.olmedo.e at gmail.com
Tue Apr 15 14:15:35 PDT 2014
Check the value returned by calloc.
---
src/evdev-mt-touchpad.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/src/evdev-mt-touchpad.c b/src/evdev-mt-touchpad.c
index bbbd8f3..9ec1682 100644
--- a/src/evdev-mt-touchpad.c
+++ b/src/evdev-mt-touchpad.c
@@ -25,6 +25,7 @@
#include <assert.h>
#include <math.h>
#include <stdbool.h>
+#include <stdio.h>
#include "evdev-mt-touchpad.h"
@@ -721,6 +722,10 @@ tp_init_slots(struct tp_dispatch *tp,
}
tp->touches = calloc(tp->ntouches,
sizeof(struct tp_touch));
+ if (!tp->touches) {
+ fprintf(stderr, "Failed to initialize slots.");
+ return -1;
+ }
return 0;
}
--
1.9.2
More information about the wayland-devel
mailing list