aboutsummaryrefslogtreecommitdiff
path: root/src/configuration.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/configuration.c16
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);
}
-