From 4fbe322fa6fcdbfda6b7006869358fdb47caff6e Mon Sep 17 00:00:00 2001 From: Tony Crisci Date: Mon, 28 Aug 2017 11:07:54 -0400 Subject: [PATCH] fix memory errors --- examples/pointer.c | 2 +- examples/touch.c | 2 +- types/wlr_cursor.c | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/examples/pointer.c b/examples/pointer.c index 8ad184424..936bfb6a2 100644 --- a/examples/pointer.c +++ b/examples/pointer.c @@ -274,7 +274,7 @@ static void handle_touch_up(struct wl_listener *listener, void *data) { static void handle_touch_down(struct wl_listener *listener, void *data) { struct sample_state *sample = wl_container_of(listener, sample, touch_down); struct wlr_event_touch_down *event = data; - struct touch_point *point = calloc(1, sizeof(struct touch_state)); + struct touch_point *point = calloc(1, sizeof(struct touch_point)); point->slot = event->slot; point->x = event->x_mm / event->width_mm; point->y = event->y_mm / event->height_mm; diff --git a/examples/touch.c b/examples/touch.c index 7e8d9827a..40fc4ca2c 100644 --- a/examples/touch.c +++ b/examples/touch.c @@ -61,7 +61,7 @@ static void handle_output_frame(struct output_state *output, struct timespec *ts static void handle_touch_down(struct touch_state *tstate, int32_t slot, double x, double y, double width, double height) { struct sample_state *sample = tstate->compositor->data; - struct touch_point *point = calloc(1, sizeof(struct touch_state)); + struct touch_point *point = calloc(1, sizeof(struct touch_point)); point->slot = slot; point->x = x / width; point->y = y / height; diff --git a/types/wlr_cursor.c b/types/wlr_cursor.c index ff19bb2b8..9f93d0d76 100644 --- a/types/wlr_cursor.c +++ b/types/wlr_cursor.c @@ -51,6 +51,7 @@ struct wlr_cursor *wlr_cursor_init() { cur->state = calloc(1, sizeof(struct wlr_cursor_state)); if (!cur->state) { wlr_log(L_ERROR, "Failed to allocate wlr_cursor_state"); + free(cur); return NULL; }