From 2950379b2f858acb2af5430526c3511a6bfa93c1 Mon Sep 17 00:00:00 2001
From: Kubat <mael.martin31@gmail.com>
Date: Thu, 9 Sep 2021 15:32:47 +0200
Subject: [PATCH] FIX: Fix the config detection when XDG_CONFIG_HOME is present
 in the ENV

---
 CHANGELOG.md      | 1 +
 src/base/config.c | 1 +
 2 files changed, 2 insertions(+)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index 518abd73..74b7de57 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -11,6 +11,7 @@
 - Fix: fix the \_\_insert command
 - Fix: linking on some platforms where the sqlite3_hard_heap_limit64 function is not present
 - Fix: Malloc the correct struct and store it into the right pointer type...
+- Fix: config detection when XDG_CONFIG_HOME is present in the ENV, we didn't update the conf path with it
 - Change: now have macros to wrap malloc calls
 - Change: use the trie data structure to be more efficient at fetching the correct command from its name at handle time (listen.c)
 - Change: enable LTO when detecting llvm compiler
diff --git a/src/base/config.c b/src/base/config.c
index 4abc2e20..0c3a74cf 100644
--- a/src/base/config.c
+++ b/src/base/config.c
@@ -192,6 +192,7 @@ config_detect_file(char *conf, size_t conf_len)
     if (home && strlen(home) < conf_len) {
         /* Skip the strncat to not append the '.config/' to
            the XDG_CONFIG_HOME which must already have this directory in it */
+        memcpy(conf, home, (strlen(home) + 1) * sizeof(char));
         strncat(conf, "/lektor/lektor.ini", conf_len - 1);
         goto skip_this_strcat;
     }
-- 
GitLab