diff --git a/CHANGELOG.md b/CHANGELOG.md
index 518abd73794c5977e832dbbcdb28cf255439a1b1..74b7de57eeb471c4db90ea3310f0e40678468104 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 4abc2e20ee83bae3cf5c4f7be943903d878100eb..0c3a74cf5e4f1d26a48b7f8a81db843dfc185aec 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;
     }