Merge pull request #1511 from emersion/scan-build-fixes

Fix two issues found with Clang's static analyzer
This commit is contained in:
Drew DeVault 2019-01-29 14:01:55 -05:00 committed by GitHub
commit 3c243ac208
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 9 deletions

View file

@ -228,13 +228,14 @@ static const struct wl_registry_listener registry_listener = {
static void frame_free(void *opaque, uint8_t *data) { static void frame_free(void *opaque, uint8_t *data) {
AVDRMFrameDescriptor *desc = (AVDRMFrameDescriptor *)data; AVDRMFrameDescriptor *desc = (AVDRMFrameDescriptor *)data;
if (desc) {
for (int i = 0; i < desc->nb_objects; ++i) { for (int i = 0; i < desc->nb_objects; ++i) {
close(desc->objects[i].fd); close(desc->objects[i].fd);
} }
av_free(data);
}
zwlr_export_dmabuf_frame_v1_destroy(opaque); zwlr_export_dmabuf_frame_v1_destroy(opaque);
av_free(data);
} }
static void frame_start(void *data, struct zwlr_export_dmabuf_frame_v1 *frame, static void frame_start(void *data, struct zwlr_export_dmabuf_frame_v1 *frame,

View file

@ -201,9 +201,10 @@ void add_binding_config(struct wl_list *bindings, const char* combination,
} }
} }
void add_switch_config(struct wl_list *switches, const char *switch_name, const char *action, void add_switch_config(struct wl_list *switches, const char *switch_name,
const char* command) { const char *action, const char *command) {
struct roots_switch_config *sc = calloc(1, sizeof(struct roots_switch_config)); struct roots_switch_config *sc =
calloc(1, sizeof(struct roots_switch_config));
if (strcmp(switch_name, "tablet") == 0) { if (strcmp(switch_name, "tablet") == 0) {
sc->switch_type = WLR_SWITCH_TYPE_TABLET_MODE; sc->switch_type = WLR_SWITCH_TYPE_TABLET_MODE;
@ -213,6 +214,7 @@ void add_switch_config(struct wl_list *switches, const char *switch_name, const
sc->switch_type = -1; sc->switch_type = -1;
sc->name = strdup(switch_name); sc->name = strdup(switch_name);
} }
if (strcmp(action, "on") == 0) { if (strcmp(action, "on") == 0) {
sc->switch_state = WLR_SWITCH_STATE_ON; sc->switch_state = WLR_SWITCH_STATE_ON;
} else if (strcmp(action, "off") == 0) { } else if (strcmp(action, "off") == 0) {
@ -220,10 +222,12 @@ void add_switch_config(struct wl_list *switches, const char *switch_name, const
} else if (strcmp(action, "toggle") == 0) { } else if (strcmp(action, "toggle") == 0) {
sc->switch_state = WLR_SWITCH_STATE_TOGGLE; sc->switch_state = WLR_SWITCH_STATE_TOGGLE;
} else { } else {
wlr_log(WLR_ERROR, "Invalid switch action %s/n for switch %s:%s", wlr_log(WLR_ERROR, "Invalid switch action %s for switch %s:%s",
action, switch_name, action); action, switch_name, action);
free(sc);
return; return;
} }
sc->command = strdup(command); sc->command = strdup(command);
wl_list_insert(switches, &sc->link); wl_list_insert(switches, &sc->link);
} }