input_config: free new_input_config on error

Found through static analysis.
master
Dominique Martinet 7 years ago
parent ebe69583c7
commit 5690bea227

@ -23,6 +23,7 @@ struct cmd_results *input_cmd_accel_profile(int argc, char **argv) {
} else if (strcasecmp(argv[0], "flat") == 0) { } else if (strcasecmp(argv[0], "flat") == 0) {
new_config->accel_profile = LIBINPUT_CONFIG_ACCEL_PROFILE_FLAT; new_config->accel_profile = LIBINPUT_CONFIG_ACCEL_PROFILE_FLAT;
} else { } else {
free_input_config(new_config);
return cmd_results_new(CMD_INVALID, "accel_profile", return cmd_results_new(CMD_INVALID, "accel_profile",
"Expected 'accel_profile <adaptive|flat>'"); "Expected 'accel_profile <adaptive|flat>'");
} }

@ -26,6 +26,7 @@ struct cmd_results *input_cmd_click_method(int argc, char **argv) {
} else if (strcasecmp(argv[0], "clickfinger") == 0) { } else if (strcasecmp(argv[0], "clickfinger") == 0) {
new_config->click_method = LIBINPUT_CONFIG_CLICK_METHOD_CLICKFINGER; new_config->click_method = LIBINPUT_CONFIG_CLICK_METHOD_CLICKFINGER;
} else { } else {
free_input_config(new_config);
return cmd_results_new(CMD_INVALID, "click_method", return cmd_results_new(CMD_INVALID, "click_method",
"Expected 'click_method <none|button_areas|clickfinger'"); "Expected 'click_method <none|button_areas|clickfinger'");
} }

@ -23,6 +23,7 @@ struct cmd_results *input_cmd_drag_lock(int argc, char **argv) {
} else if (strcasecmp(argv[0], "disabled") == 0) { } else if (strcasecmp(argv[0], "disabled") == 0) {
new_config->drag_lock = LIBINPUT_CONFIG_DRAG_LOCK_DISABLED; new_config->drag_lock = LIBINPUT_CONFIG_DRAG_LOCK_DISABLED;
} else { } else {
free_input_config(new_config);
return cmd_results_new(CMD_INVALID, "drag_lock", return cmd_results_new(CMD_INVALID, "drag_lock",
"Expected 'drag_lock <enabled|disabled>'"); "Expected 'drag_lock <enabled|disabled>'");
} }

@ -22,6 +22,7 @@ struct cmd_results *input_cmd_dwt(int argc, char **argv) {
} else if (strcasecmp(argv[0], "disabled") == 0) { } else if (strcasecmp(argv[0], "disabled") == 0) {
new_config->dwt = LIBINPUT_CONFIG_DWT_DISABLED; new_config->dwt = LIBINPUT_CONFIG_DWT_DISABLED;
} else { } else {
free_input_config(new_config);
return cmd_results_new(CMD_INVALID, "dwt", return cmd_results_new(CMD_INVALID, "dwt",
"Expected 'dwt <enabled|disabled>'"); "Expected 'dwt <enabled|disabled>'");
} }

@ -29,6 +29,7 @@ struct cmd_results *input_cmd_events(int argc, char **argv) {
new_config->send_events = new_config->send_events =
LIBINPUT_CONFIG_SEND_EVENTS_DISABLED_ON_EXTERNAL_MOUSE; LIBINPUT_CONFIG_SEND_EVENTS_DISABLED_ON_EXTERNAL_MOUSE;
} else { } else {
free_input_config(new_config);
return cmd_results_new(CMD_INVALID, "events", return cmd_results_new(CMD_INVALID, "events",
"Expected 'events <enabled|disabled|disabled_on_external_mouse>'"); "Expected 'events <enabled|disabled|disabled_on_external_mouse>'");
} }

@ -23,6 +23,7 @@ struct cmd_results *input_cmd_left_handed(int argc, char **argv) {
} else if (strcasecmp(argv[0], "disabled") == 0) { } else if (strcasecmp(argv[0], "disabled") == 0) {
new_config->left_handed = 0; new_config->left_handed = 0;
} else { } else {
free_input_config(new_config);
return cmd_results_new(CMD_INVALID, "left_handed", return cmd_results_new(CMD_INVALID, "left_handed",
"Expected 'left_handed <enabled|disabled>'"); "Expected 'left_handed <enabled|disabled>'");
} }

@ -54,20 +54,28 @@ struct cmd_results *input_cmd_map_from_region(int argc, char **argv) {
bool mm1, mm2; bool mm1, mm2;
if (!parse_coords(argv[0], &new_config->mapped_from_region->x1, if (!parse_coords(argv[0], &new_config->mapped_from_region->x1,
&new_config->mapped_from_region->y1, &mm1)) { &new_config->mapped_from_region->y1, &mm1)) {
free(new_config->mapped_from_region);
free_input_config(new_config);
return cmd_results_new(CMD_FAILURE, "map_from_region", return cmd_results_new(CMD_FAILURE, "map_from_region",
"Invalid top-left coordinates"); "Invalid top-left coordinates");
} }
if (!parse_coords(argv[1], &new_config->mapped_from_region->x2, if (!parse_coords(argv[1], &new_config->mapped_from_region->x2,
&new_config->mapped_from_region->y2, &mm2)) { &new_config->mapped_from_region->y2, &mm2)) {
free(new_config->mapped_from_region);
free_input_config(new_config);
return cmd_results_new(CMD_FAILURE, "map_from_region", return cmd_results_new(CMD_FAILURE, "map_from_region",
"Invalid bottom-right coordinates"); "Invalid bottom-right coordinates");
} }
if (new_config->mapped_from_region->x1 > new_config->mapped_from_region->x2 || if (new_config->mapped_from_region->x1 > new_config->mapped_from_region->x2 ||
new_config->mapped_from_region->y1 > new_config->mapped_from_region->y2) { new_config->mapped_from_region->y1 > new_config->mapped_from_region->y2) {
free(new_config->mapped_from_region);
free_input_config(new_config);
return cmd_results_new(CMD_FAILURE, "map_from_region", return cmd_results_new(CMD_FAILURE, "map_from_region",
"Invalid rectangle"); "Invalid rectangle");
} }
if (mm1 != mm2) { if (mm1 != mm2) {
free(new_config->mapped_from_region);
free_input_config(new_config);
return cmd_results_new(CMD_FAILURE, "map_from_region", return cmd_results_new(CMD_FAILURE, "map_from_region",
"Both coordinates must be in the same unit"); "Both coordinates must be in the same unit");
} }

@ -24,6 +24,7 @@ struct cmd_results *input_cmd_middle_emulation(int argc, char **argv) {
new_config->middle_emulation = new_config->middle_emulation =
LIBINPUT_CONFIG_MIDDLE_EMULATION_DISABLED; LIBINPUT_CONFIG_MIDDLE_EMULATION_DISABLED;
} else { } else {
free_input_config(new_config);
return cmd_results_new(CMD_INVALID, "middle_emulation", return cmd_results_new(CMD_INVALID, "middle_emulation",
"Expected 'middle_emulation <enabled|disabled>'"); "Expected 'middle_emulation <enabled|disabled>'");
} }

@ -23,6 +23,7 @@ struct cmd_results *input_cmd_natural_scroll(int argc, char **argv) {
} else if (strcasecmp(argv[0], "disabled") == 0) { } else if (strcasecmp(argv[0], "disabled") == 0) {
new_config->natural_scroll = 0; new_config->natural_scroll = 0;
} else { } else {
free_input_config(new_config);
return cmd_results_new(CMD_INVALID, "natural_scroll", return cmd_results_new(CMD_INVALID, "natural_scroll",
"Expected 'natural_scroll <enabled|disabled>'"); "Expected 'natural_scroll <enabled|disabled>'");
} }

@ -20,6 +20,7 @@ struct cmd_results *input_cmd_pointer_accel(int argc, char **argv) {
float pointer_accel = atof(argv[0]); float pointer_accel = atof(argv[0]);
if (pointer_accel < -1 || pointer_accel > 1) { if (pointer_accel < -1 || pointer_accel > 1) {
free_input_config(new_config);
return cmd_results_new(CMD_INVALID, "pointer_accel", return cmd_results_new(CMD_INVALID, "pointer_accel",
"Input out of range [-1, 1]"); "Input out of range [-1, 1]");
} }

@ -20,6 +20,7 @@ struct cmd_results *input_cmd_repeat_delay(int argc, char **argv) {
int repeat_delay = atoi(argv[0]); int repeat_delay = atoi(argv[0]);
if (repeat_delay < 0) { if (repeat_delay < 0) {
free_input_config(new_config);
return cmd_results_new(CMD_INVALID, "repeat_delay", return cmd_results_new(CMD_INVALID, "repeat_delay",
"Repeat delay cannot be negative"); "Repeat delay cannot be negative");
} }

@ -20,6 +20,7 @@ struct cmd_results *input_cmd_repeat_rate(int argc, char **argv) {
int repeat_rate = atoi(argv[0]); int repeat_rate = atoi(argv[0]);
if (repeat_rate < 0) { if (repeat_rate < 0) {
free_input_config(new_config);
return cmd_results_new(CMD_INVALID, "repeat_rate", return cmd_results_new(CMD_INVALID, "repeat_rate",
"Repeat rate cannot be negative"); "Repeat rate cannot be negative");
} }

@ -27,6 +27,7 @@ struct cmd_results *input_cmd_scroll_method(int argc, char **argv) {
} else if (strcasecmp(argv[0], "on_button_down") == 0) { } else if (strcasecmp(argv[0], "on_button_down") == 0) {
new_config->scroll_method = LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN; new_config->scroll_method = LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN;
} else { } else {
free_input_config(new_config);
return cmd_results_new(CMD_INVALID, "scroll_method", return cmd_results_new(CMD_INVALID, "scroll_method",
"Expected 'scroll_method <none|two_finger|edge|on_button_down>'"); "Expected 'scroll_method <none|two_finger|edge|on_button_down>'");
} }

@ -23,6 +23,7 @@ struct cmd_results *input_cmd_tap(int argc, char **argv) {
} else if (strcasecmp(argv[0], "disabled") == 0) { } else if (strcasecmp(argv[0], "disabled") == 0) {
new_config->tap = LIBINPUT_CONFIG_TAP_DISABLED; new_config->tap = LIBINPUT_CONFIG_TAP_DISABLED;
} else { } else {
free_input_config(new_config);
return cmd_results_new(CMD_INVALID, "tap", return cmd_results_new(CMD_INVALID, "tap",
"Expected 'tap <enabled|disabled>'"); "Expected 'tap <enabled|disabled>'");
} }

Loading…
Cancel
Save