summaryrefslogtreecommitdiff
path: root/src/surface/wld.c
diff options
context:
space:
mode:
authorVincent Sanders <vince@kyllikki.org>2017-10-15 13:43:35 +0100
committerVincent Sanders <vince@kyllikki.org>2017-10-15 13:51:05 +0100
commit71d303a1805b454395b9b2ed4d1007699b9d1314 (patch)
tree99176bb9155b9c49fea2028ed9747dfb5dae65f6 /src/surface/wld.c
parent167205c109291aa1957ba64667efa12ce53bba5d (diff)
downloadlibnsfb-71d303a1805b454395b9b2ed4d1007699b9d1314.tar.gz
libnsfb-71d303a1805b454395b9b2ed4d1007699b9d1314.tar.bz2
fix unchecked heap allocation returns
Alastair Hughes provided a patch in the bug tracker which I based this implementation upon. Closes: #2553
Diffstat (limited to 'src/surface/wld.c')
-rw-r--r--src/surface/wld.c26
1 files changed, 15 insertions, 11 deletions
diff --git a/src/surface/wld.c b/src/surface/wld.c
index 29f9ae2..9ef3c40 100644
--- a/src/surface/wld.c
+++ b/src/surface/wld.c
@@ -48,7 +48,7 @@ struct wld_connection {
struct wl_display *display; /**< connection object */
struct wl_registry *registry; /**< registry object */
- /** compositor object, available once teh registry messages have
+ /** compositor object, available once the registry messages have
* been processed
*/
struct wl_compositor *compositor;
@@ -975,13 +975,14 @@ pointer_handle_motion(void *data,
UNUSED(time);
event = calloc(1, sizeof(struct wld_event));
+ if (event != NULL) {
+ event->event.type = NSFB_EVENT_MOVE_ABSOLUTE;
+ event->event.value.vector.x = wl_fixed_to_int(sx_w);
+ event->event.value.vector.y = wl_fixed_to_int(sy_w);
+ event->event.value.vector.z = 0;
- event->event.type = NSFB_EVENT_MOVE_ABSOLUTE;
- event->event.value.vector.x = wl_fixed_to_int(sx_w);
- event->event.value.vector.y = wl_fixed_to_int(sy_w);
- event->event.value.vector.z = 0;
-
- enqueue_wld_event(input->connection, event);
+ enqueue_wld_event(input->connection, event);
+ }
}
static void
@@ -997,7 +998,9 @@ pointer_handle_button(void *data, struct wl_pointer *pointer, uint32_t serial,
UNUSED(time);
event = calloc(1, sizeof(struct wld_event));
-
+ if (event == NULL) {
+ return;
+ }
if (state == WL_POINTER_BUTTON_STATE_PRESSED) {
event->event.type = NSFB_EVENT_KEY_DOWN;
} else {
@@ -1259,7 +1262,6 @@ new_connection(void)
struct wld_connection* connection;
connection = calloc(1, sizeof(struct wld_connection));
-
if (connection == NULL) {
return NULL;
}
@@ -1456,8 +1458,9 @@ os_create_anonymous_file(off_t size)
}
name = malloc(strlen(path) + sizeof(template));
- if (!name)
+ if (name == NULL) {
return -1;
+ }
strcpy(name, path);
strcat(name, template);
@@ -1657,8 +1660,9 @@ static int x_initialise(nsfb_t *nsfb)
return -1;
xstate = calloc(1, sizeof(xstate_t));
- if (xstate == NULL)
+ if (xstate == NULL) {
return -1; /* no memory */
+ }
/* open connection with the server */
xstate->connection = xcb_connect(NULL, NULL);