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

_______________________________________________
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/wayland-devel

Reply via email to