fixup strdup() from the last patch

This commit is contained in:
Hiltjo Posthuma 2020-08-04 23:12:03 +02:00
parent 3d03b522e0
commit 9f5404990d

View File

@ -886,7 +886,6 @@ main(int argc, char *argv[]) {
signal(SIGTERM, sigterm); signal(SIGTERM, sigterm);
/* parse environment variables */ /* parse environment variables */
if (OVERLAYS <= 1) { if (OVERLAYS <= 1) {
enableoverlays = 0; enableoverlays = 0;
@ -894,9 +893,9 @@ main(int argc, char *argv[]) {
const char* enableoverlays_env = getenv("SVKBD_ENABLEOVERLAYS"); const char* enableoverlays_env = getenv("SVKBD_ENABLEOVERLAYS");
if (enableoverlays_env != NULL) enableoverlays = atoi(enableoverlays_env); if (enableoverlays_env != NULL) enableoverlays = atoi(enableoverlays_env);
} }
const char* layers_env = getenv("SVKBD_LAYERS"); char *layers_env = getenv("SVKBD_LAYERS");
if (layers_env != NULL) { if (layers_env != NULL) {
if (!strdup(layer_names_list, layers_env)) { if (!(layer_names_list = strdup(layers_env))) {
die("memory allocation error\n"); die("memory allocation error\n");
} }
} }
@ -942,7 +941,7 @@ main(int argc, char *argv[]) {
if(i >= argc - 1) if(i >= argc - 1)
continue; continue;
free(layer_names_list); free(layer_names_list);
if (!strdup(layer_names_list, argv[++i])) { if (!(layer_names_list = strdup(argv[++i]))) {
die("memory allocation error\n"); die("memory allocation error\n");
} }
} else if(!strcmp(argv[i], "-s")) { } else if(!strcmp(argv[i], "-s")) {