adding some minor error catching
This commit is contained in:
parent
4dab556580
commit
12fe4c8923
10
svkbd.c
10
svkbd.c
@ -886,6 +886,7 @@ main(int argc, char *argv[]) {
|
|||||||
const char* layers_env = getenv("SVKBD_LAYERS");
|
const char* layers_env = getenv("SVKBD_LAYERS");
|
||||||
if (layers_env != NULL) {
|
if (layers_env != NULL) {
|
||||||
layer_names_list = malloc(128);
|
layer_names_list = malloc(128);
|
||||||
|
if (!layer_names_list) die("memory allocation error\n");
|
||||||
strcpy(layer_names_list, layers_env);
|
strcpy(layer_names_list, layers_env);
|
||||||
}
|
}
|
||||||
const char* heightfactor_s = getenv("SVKBD_HEIGHTFACTOR");
|
const char* heightfactor_s = getenv("SVKBD_HEIGHTFACTOR");
|
||||||
@ -929,7 +930,10 @@ main(int argc, char *argv[]) {
|
|||||||
} else if(!strcmp(argv[i], "-l")) {
|
} else if(!strcmp(argv[i], "-l")) {
|
||||||
if(i >= argc - 1)
|
if(i >= argc - 1)
|
||||||
continue;
|
continue;
|
||||||
if (layer_names_list == NULL) layer_names_list = malloc(128);
|
if (layer_names_list == NULL) {
|
||||||
|
layer_names_list = malloc(128);
|
||||||
|
if (!layer_names_list) die("memory allocation error\n");
|
||||||
|
}
|
||||||
strcpy(layer_names_list, argv[++i]);
|
strcpy(layer_names_list, argv[++i]);
|
||||||
} else if(!strcmp(argv[i], "-s")) {
|
} else if(!strcmp(argv[i], "-s")) {
|
||||||
if(i >= argc - 1)
|
if(i >= argc - 1)
|
||||||
@ -945,6 +949,8 @@ main(int argc, char *argv[]) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (heightfactor <= 0) die("height factor must be a positive integer\n");
|
||||||
|
|
||||||
init_layers(layer_names_list, initial_layer_name);
|
init_layers(layer_names_list, initial_layer_name);
|
||||||
|
|
||||||
if(!setlocale(LC_CTYPE, "") || !XSupportsLocale())
|
if(!setlocale(LC_CTYPE, "") || !XSupportsLocale())
|
||||||
@ -955,6 +961,6 @@ main(int argc, char *argv[]) {
|
|||||||
run();
|
run();
|
||||||
cleanup();
|
cleanup();
|
||||||
XCloseDisplay(dpy);
|
XCloseDisplay(dpy);
|
||||||
if (layer_names_list != NULL) free(layer_names_list);
|
free(layer_names_list);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user