Fix a bunch of mistakes detected with scan-build

This commit is contained in:
emersion 2017-11-16 10:30:54 +01:00
parent ac78c6642a
commit bb79ada49f
No known key found for this signature in database
GPG key ID: 0FDE7BE0E88F5E48
10 changed files with 19 additions and 9 deletions

View file

@ -636,7 +636,10 @@ static void data_device_start_drag(struct wl_client *client,
if (!seat_client_start_drag(seat_client, source, icon)) {
wl_resource_post_no_memory(device_resource);
} else {
return;
}
if (source) {
source->seat_client = seat_client;
}
}

View file

@ -105,7 +105,10 @@ void wlr_keyboard_init(struct wlr_keyboard *kb,
}
void wlr_keyboard_destroy(struct wlr_keyboard *kb) {
if (kb && kb->impl && kb->impl->destroy) {
if (kb == NULL) {
return;
}
if (kb->impl && kb->impl->destroy) {
kb->impl->destroy(kb);
} else {
wl_list_remove(&kb->events.key.listener_list);

View file

@ -85,6 +85,7 @@ static void screenshooter_shoot(struct wl_client *client,
struct wlr_screenshot *screenshot =
calloc(1, sizeof(struct wlr_screenshot));
if (!screenshot) {
free(pixels);
wl_resource_post_no_memory(screenshooter_resource);
return;
}
@ -96,6 +97,7 @@ static void screenshooter_shoot(struct wl_client *client,
wl_resource_get_version(screenshooter_resource), id);
if (screenshot->resource == NULL) {
free(screenshot);
free(pixels);
wl_resource_post_no_memory(screenshooter_resource);
return;
}
@ -109,6 +111,7 @@ static void screenshooter_shoot(struct wl_client *client,
if (!state) {
wl_resource_destroy(screenshot->resource);
free(screenshot);
free(pixels);
wl_resource_post_no_memory(screenshooter_resource);
return;
}

View file

@ -347,7 +347,7 @@ static void shell_surface_protocol_set_popup(struct wl_client *client,
transient_state->flags = flags;
struct wlr_wl_shell_surface_popup_state *popup_state =
calloc(1, sizeof(struct wlr_wl_shell_surface_transient_state));
calloc(1, sizeof(struct wlr_wl_shell_surface_popup_state));
if (popup_state == NULL) {
free(transient_state);
wl_client_post_no_memory(client);