diff options
author | axtlos <rose@pinkro.se> | 2025-06-19 00:47:45 +0200 |
---|---|---|
committer | axtlos <rose@pinkro.se> | 2025-06-19 00:47:45 +0200 |
commit | cd3b65bd1c2d84780f916bb61aea616ff65f6d7d (patch) | |
tree | 71eef403d9de916e68a3b9becc70c433e1f62a16 /src/configuration.c | |
parent | 7654df2f9cb61572636183887d0832e448957689 (diff) | |
download | autodarkmode-main.tar.gz autodarkmode-main.tar.bz2 |
Diffstat (limited to '')
-rw-r--r-- | src/configuration.c | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/src/configuration.c b/src/configuration.c index 7d978f6..1bf9eb9 100644 --- a/src/configuration.c +++ b/src/configuration.c @@ -1,6 +1,6 @@ /* configuration.c * - * Copyright 2024 axtlos <axtlos@disroot.org> + * Copyright 2025 Rose <rose@pinkro.se> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -31,18 +31,21 @@ dictionary * load_config(void) { char *xdg_config = getenv ("XDG_CONFIG_HOME"); - char *home = getenv ("HOME"); - if (home == NULL) - return NULL; if (xdg_config == NULL) { + char *home = getenv ("HOME"); + if (home == NULL) + return NULL; + + // the getenv output cannot be freed, it results in a segfault + // but this one should be freed, as it is manually allocated + // however this isnt freed. that is bad. i am too lazy to free it properly + // autodarkmode can leak some memory, as a treat xdg_config = malloc (strlen(home)*sizeof(char)+strlen("/.config")*sizeof(char)+1); sprintf (xdg_config, "%s/.config", home); } char *config_path = malloc(strlen(xdg_config)*sizeof(char)+strlen("/autodarkmode/config.ini")*sizeof(char)+1); sprintf (config_path, "%s/autodarkmode/config.ini", xdg_config); - free (xdg_config); - if (access(config_path, F_OK) != 0) { g_printerr ("Config file not found. Using default values.\n"); free (config_path); @@ -93,4 +96,3 @@ config_get_longitude (dictionary *d) return iniparser_getdouble (d, "manual:longitude", 0); } - |