mirror of
https://github.com/swaywm/sway.git
synced 2024-11-14 06:24:20 +01:00
fix a few possible memory leaks
This commit is contained in:
parent
6dc1ae802b
commit
95517ac77e
@ -105,6 +105,10 @@ static bool cmd_bindsym(struct sway_config *config, int argc, char **argv) {
|
|||||||
xkb_keysym_t sym = xkb_keysym_from_name(split->items[i], XKB_KEYSYM_CASE_INSENSITIVE);
|
xkb_keysym_t sym = xkb_keysym_from_name(split->items[i], XKB_KEYSYM_CASE_INSENSITIVE);
|
||||||
if (!sym) {
|
if (!sym) {
|
||||||
sway_log(L_ERROR, "bindsym - unknown key %s", (char *)split->items[i]);
|
sway_log(L_ERROR, "bindsym - unknown key %s", (char *)split->items[i]);
|
||||||
|
list_free(binding->keys);
|
||||||
|
free(binding->command);
|
||||||
|
free(binding);
|
||||||
|
list_free(split);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
xkb_keysym_t *key = malloc(sizeof(xkb_keysym_t));
|
xkb_keysym_t *key = malloc(sizeof(xkb_keysym_t));
|
||||||
|
@ -28,6 +28,7 @@ static char *get_config_path() {
|
|||||||
if (exists(temp)) {
|
if (exists(temp)) {
|
||||||
return temp;
|
return temp;
|
||||||
}
|
}
|
||||||
|
free(temp);
|
||||||
|
|
||||||
// Check XDG_CONFIG_HOME with fallback to ~/.config/
|
// Check XDG_CONFIG_HOME with fallback to ~/.config/
|
||||||
sway_log(L_DEBUG, "Trying to find config in XDG_CONFIG_HOME/sway/config");
|
sway_log(L_DEBUG, "Trying to find config in XDG_CONFIG_HOME/sway/config");
|
||||||
@ -54,6 +55,7 @@ static char *get_config_path() {
|
|||||||
if (exists(temp)) {
|
if (exists(temp)) {
|
||||||
return temp;
|
return temp;
|
||||||
}
|
}
|
||||||
|
free(temp);
|
||||||
|
|
||||||
// Check XDG_CONFIG_DIRS
|
// Check XDG_CONFIG_DIRS
|
||||||
sway_log(L_DEBUG, "Trying to find config in XDG_CONFIG_DIRS");
|
sway_log(L_DEBUG, "Trying to find config in XDG_CONFIG_DIRS");
|
||||||
@ -70,6 +72,7 @@ static char *get_config_path() {
|
|||||||
free_flat_list(paths);
|
free_flat_list(paths);
|
||||||
return temp;
|
return temp;
|
||||||
}
|
}
|
||||||
|
free(temp);
|
||||||
}
|
}
|
||||||
free_flat_list(paths);
|
free_flat_list(paths);
|
||||||
}
|
}
|
||||||
@ -83,6 +86,7 @@ static char *get_config_path() {
|
|||||||
if (exists(temp)) {
|
if (exists(temp)) {
|
||||||
return temp;
|
return temp;
|
||||||
}
|
}
|
||||||
|
free(temp);
|
||||||
|
|
||||||
sway_log(L_DEBUG, "Trying to find config in XDG_CONFIG_HOME/i3/config");
|
sway_log(L_DEBUG, "Trying to find config in XDG_CONFIG_HOME/i3/config");
|
||||||
if (xdg_config_home == NULL) {
|
if (xdg_config_home == NULL) {
|
||||||
@ -106,6 +110,7 @@ static char *get_config_path() {
|
|||||||
if (exists(temp)) {
|
if (exists(temp)) {
|
||||||
return temp;
|
return temp;
|
||||||
}
|
}
|
||||||
|
free(temp);
|
||||||
|
|
||||||
sway_log(L_DEBUG, "Trying to find config in XDG_CONFIG_DIRS");
|
sway_log(L_DEBUG, "Trying to find config in XDG_CONFIG_DIRS");
|
||||||
if (xdg_config_dirs != NULL) {
|
if (xdg_config_dirs != NULL) {
|
||||||
@ -120,6 +125,7 @@ static char *get_config_path() {
|
|||||||
free_flat_list(paths);
|
free_flat_list(paths);
|
||||||
return temp;
|
return temp;
|
||||||
}
|
}
|
||||||
|
free(temp);
|
||||||
}
|
}
|
||||||
free_flat_list(paths);
|
free_flat_list(paths);
|
||||||
}
|
}
|
||||||
|
@ -42,10 +42,14 @@ char *workspace_next_name(void) {
|
|||||||
strcmp(target, "number") == 0 ||
|
strcmp(target, "number") == 0 ||
|
||||||
strcmp(target, "back_and_forth") == 0 ||
|
strcmp(target, "back_and_forth") == 0 ||
|
||||||
strcmp(target, "current") == 0)
|
strcmp(target, "current") == 0)
|
||||||
|
{
|
||||||
|
list_free(args);
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
//Make sure that the workspace doesn't already exist
|
//Make sure that the workspace doesn't already exist
|
||||||
if (workspace_find_by_name(target)) {
|
if (workspace_find_by_name(target)) {
|
||||||
|
list_free(args);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -54,6 +58,7 @@ char *workspace_next_name(void) {
|
|||||||
sway_log(L_DEBUG, "Workspace: Found free name %s", target);
|
sway_log(L_DEBUG, "Workspace: Found free name %s", target);
|
||||||
return target;
|
return target;
|
||||||
}
|
}
|
||||||
|
list_free(args);
|
||||||
}
|
}
|
||||||
// As a fall back, get the current number of active workspaces
|
// As a fall back, get the current number of active workspaces
|
||||||
// and return that + 1 for the next workspace's name
|
// and return that + 1 for the next workspace's name
|
||||||
|
Loading…
Reference in New Issue
Block a user