Skip to content

Commit d4c836f

Browse files
Handle empty xdg env vars better
1 parent 6787f1e commit d4c836f

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

src/common/init.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#include "fastfetch.h"
22
#include "common/caching.h"
3+
#include "common/parsing.h"
34
#include "detection/qt.h"
45
#include "detection/gtk.h"
56
#include "detection/displayserver.h"
@@ -20,7 +21,7 @@ static void initConfigDirs(FFstate* state)
2021
ffListInit(&state->configDirs, sizeof(FFstrbuf));
2122

2223
const char* xdgConfigHome = getenv("XDG_CONFIG_HOME");
23-
if(xdgConfigHome != NULL)
24+
if(ffStrSet(xdgConfigHome))
2425
{
2526
FFstrbuf* buffer = (FFstrbuf*) ffListAdd(&state->configDirs);
2627
ffStrbufInitA(buffer, 64);
@@ -54,6 +55,12 @@ static void initConfigDirs(FFstate* state)
5455
uint32_t colonIndex = ffStrbufNextIndexC(&xdgConfigDirs, startIndex, ':');
5556
xdgConfigDirs.chars[colonIndex] = '\0';
5657

58+
if(!ffStrSet(xdgConfigDirs.chars + startIndex))
59+
{
60+
startIndex = colonIndex + 1;
61+
continue;
62+
}
63+
5764
FFstrbuf* buffer = (FFstrbuf*) ffListAdd(&state->configDirs);
5865
ffStrbufInitA(buffer, 64);
5966
ffStrbufAppendS(buffer, xdgConfigDirs.chars + startIndex);

src/detection/gtk.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -107,11 +107,6 @@ static void detectGTKFromConfigFile(const char* filename, FFGTKResult* result)
107107

108108
static void detectGTKFromConfigDir(FFstrbuf* configDir, const char* version, FFGTKResult* result)
109109
{
110-
//In case of an empty env variable
111-
ffStrbufTrim(configDir, ' ');
112-
if(configDir->length == 0)
113-
return;
114-
115110
uint32_t configDirLength = configDir->length;
116111

117112
// <configdir>/gtk-<version>.0/settings.ini

0 commit comments

Comments
 (0)