mirror of
https://github.com/hyprwm/xdg-desktop-portal-hyprland.git
synced 2024-11-22 22:35:59 +01:00
config: handle missing HOME env variable gracefully
Fixes: https://github.com/emersion/xdg-desktop-portal-wlr/issues/149
This commit is contained in:
parent
71730982da
commit
6438edb7b9
1 changed files with 6 additions and 3 deletions
|
@ -106,9 +106,12 @@ static char *config_path(const char *prefix, const char *filename) {
|
||||||
|
|
||||||
static char *get_config_path(void) {
|
static char *get_config_path(void) {
|
||||||
const char *home = getenv("HOME");
|
const char *home = getenv("HOME");
|
||||||
size_t size_fallback = 1 + strlen(home) + strlen("/.config");
|
char *config_home_fallback = NULL;
|
||||||
char *config_home_fallback = calloc(size_fallback, sizeof(char));
|
if (home != NULL && home[0] != '\0') {
|
||||||
snprintf(config_home_fallback, size_fallback, "%s/.config", home);
|
size_t size_fallback = 1 + strlen(home) + strlen("/.config");
|
||||||
|
config_home_fallback = calloc(size_fallback, sizeof(char));
|
||||||
|
snprintf(config_home_fallback, size_fallback, "%s/.config", home);
|
||||||
|
}
|
||||||
|
|
||||||
const char *config_home = getenv("XDG_CONFIG_HOME");
|
const char *config_home = getenv("XDG_CONFIG_HOME");
|
||||||
if (config_home == NULL || config_home[0] == '\0') {
|
if (config_home == NULL || config_home[0] == '\0') {
|
||||||
|
|
Loading…
Reference in a new issue