aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--types/wlr_seat.c4
-rw-r--r--types/wlr_surface.c18
-rw-r--r--types/wlr_tablet_tool.c4
-rw-r--r--types/wlr_wl_shell.c1
4 files changed, 18 insertions, 9 deletions
diff --git a/types/wlr_seat.c b/types/wlr_seat.c
index f8e9645f..1563c300 100644
--- a/types/wlr_seat.c
+++ b/types/wlr_seat.c
@@ -206,6 +206,10 @@ static void wl_seat_bind(struct wl_client *client, void *_wlr_seat,
struct wlr_seat_client *seat_client =
calloc(1, sizeof(struct wlr_seat_client));
+ if (seat_client == NULL) {
+ wl_client_post_no_memory(client);
+ return;
+ }
seat_client->wl_resource =
wl_resource_create(client, &wl_seat_interface, version, id);
seat_client->client = client;
diff --git a/types/wlr_surface.c b/types/wlr_surface.c
index 72996157..2a8c4d04 100644
--- a/types/wlr_surface.c
+++ b/types/wlr_surface.c
@@ -78,17 +78,17 @@ static void destroy_frame_callback(struct wl_resource *resource) {
static void surface_frame(struct wl_client *client,
struct wl_resource *resource, uint32_t callback) {
- struct wlr_frame_callback *cb;
struct wlr_surface *surface = wl_resource_get_user_data(resource);
- cb = malloc(sizeof(struct wlr_frame_callback));
+ struct wlr_frame_callback *cb =
+ calloc(1, sizeof(struct wlr_frame_callback));
if (cb == NULL) {
wl_resource_post_no_memory(resource);
return;
}
- cb->resource = wl_resource_create(client,
- &wl_callback_interface, 1, callback);
+ cb->resource = wl_resource_create(client, &wl_callback_interface, 1,
+ callback);
if (cb->resource == NULL) {
free(cb);
wl_resource_post_no_memory(resource);
@@ -555,7 +555,11 @@ const struct wl_surface_interface surface_interface = {
};
static struct wlr_surface_state *wlr_surface_state_create() {
- struct wlr_surface_state *state = calloc(1, sizeof(struct wlr_surface_state));
+ struct wlr_surface_state *state =
+ calloc(1, sizeof(struct wlr_surface_state));
+ if (state == NULL) {
+ return NULL;
+ }
state->scale = 1;
state->transform = WL_OUTPUT_TRANSFORM_NORMAL;
@@ -619,8 +623,8 @@ static void destroy_surface(struct wl_resource *resource) {
struct wlr_surface *wlr_surface_create(struct wl_resource *res,
struct wlr_renderer *renderer) {
- struct wlr_surface *surface;
- if (!(surface = calloc(1, sizeof(struct wlr_surface)))) {
+ struct wlr_surface *surface = calloc(1, sizeof(struct wlr_surface));
+ if (!surface) {
wl_resource_post_no_memory(res);
return NULL;
}
diff --git a/types/wlr_tablet_tool.c b/types/wlr_tablet_tool.c
index 9f12a5ba..a396bb02 100644
--- a/types/wlr_tablet_tool.c
+++ b/types/wlr_tablet_tool.c
@@ -14,7 +14,9 @@ void wlr_tablet_tool_init(struct wlr_tablet_tool *tool,
}
void wlr_tablet_tool_destroy(struct wlr_tablet_tool *tool) {
- if (!tool) return;
+ if (!tool) {
+ return;
+ }
if (tool->impl && tool->impl->destroy) {
tool->impl->destroy(tool);
} else {
diff --git a/types/wlr_wl_shell.c b/types/wlr_wl_shell.c
index 3acb99cd..dd1f10b2 100644
--- a/types/wlr_wl_shell.c
+++ b/types/wlr_wl_shell.c
@@ -22,7 +22,6 @@ static void shell_pointer_grab_end(struct wlr_seat_pointer_grab *grab) {
}
}
-
if (grab->seat->pointer_state.grab == grab) {
wlr_seat_pointer_end_grab(grab->seat);
}