Remove usage of VLAs.

This commit is contained in:
Connor E 2019-01-16 01:57:53 +00:00 committed by emersion
parent 02bbefda20
commit aa9d7d8ca1
7 changed files with 32 additions and 11 deletions

View file

@ -365,11 +365,12 @@ int swaynag_load_config(char *path, struct swaynag *swaynag, list_t *types) {
}
free(name);
} else {
char flag[nread + 3];
char *flag = malloc(sizeof(char) * (nread + 3));
sprintf(flag, "--%s", line);
char *argv[] = {"swaynag", flag};
result = swaynag_parse_options(2, argv, swaynag, types, type,
NULL, NULL);
free(flag);
if (result != 0) {
break;
}

View file

@ -28,9 +28,10 @@ static bool terminal_execute(char *terminal, char *command) {
fprintf(tmp, "#!/bin/sh\nrm %s\n%s", fname, command);
fclose(tmp);
chmod(fname, S_IRUSR | S_IWUSR | S_IXUSR);
char cmd[strlen(terminal) + strlen(" -e ") + strlen(fname) + 1];
char *cmd = malloc(sizeof(char) * (strlen(terminal) + strlen(" -e ") + strlen(fname) + 1));
sprintf(cmd, "%s -e %s", terminal, fname);
execl("/bin/sh", "/bin/sh", "-c", cmd, NULL);
free(cmd);
return true;
}