Leak sanitizer: no false positives

This commit is contained in:
Linus Dierheimer
2022-09-22 22:02:58 +02:00
parent 991d02e2c0
commit 3d0653025e
7 changed files with 32 additions and 6 deletions
+1
View File
@@ -15,4 +15,5 @@ else
fi
cmake --build . --target fastfetch ${cmake_build_extra_args}
export LSAN_OPTIONS=suppressions=../tests/lsan.supp
./fastfetch "$@"
+7 -2
View File
@@ -132,7 +132,7 @@ static void initModuleArg(FFModuleArgs* args)
static void defaultConfig(FFinstance* instance)
{
ffStrbufInit(&instance->config.logo.source);
ffStrbufInitA(&instance->config.logo.source, 0);
instance->config.logo.type = FF_LOGO_TYPE_AUTO;
for(uint8_t i = 0; i < (uint8_t) FASTFETCH_LOGO_MAX_COLORS; ++i)
ffStrbufInit(&instance->config.logo.colors[i]);
@@ -383,17 +383,22 @@ void ffFinish(FFinstance* instance)
ffLogoPrintRemaining(instance);
resetConsole();
}
void ffDestroyInstance(FFinstance* instance)
{
for(uint32_t i = 0; i < instance->state.configDirs.length; ++i)
ffStrbufDestroy((FFstrbuf*)ffListGet(&instance->state.configDirs, i));
ffListDestroy(&instance->state.configDirs);
ffStrbufDestroy(&instance->state.cacheDir);
for(uint8_t i = 0; i < (uint8_t) FASTFETCH_LOGO_MAX_COLORS; ++i)
ffStrbufDestroy(&instance->config.logo.colors[i]);
ffStrbufDestroy(&instance->config.colorKeys);
ffStrbufDestroy(&instance->config.colorTitle);
ffStrbufDestroy(&instance->config.separator);
ffStrbufDestroy(&instance->config.logo.source);
}
//Must be in a file compiled with the libfastfetch target, because the FF_HAVE* macros are not defined for the executable targets
+16 -3
View File
@@ -3,9 +3,22 @@
#include <stdarg.h>
//Clang doesn't define __SANITIZE_ADDRESS__ but defines __has_feature(address_sanitizer)
#if defined(__has_feature)
#if __has_feature(address_sanitizer)
#define __SANITIZE_ADDRESS__
#endif
#endif
#ifdef __SANITIZE_ADDRESS__
#define FF_DLOPEN_FLAGS RTLD_LAZY | RTLD_NODELETE
#else
#define FF_DLOPEN_FLAGS RTLD_LAZY
#endif
static void* libraryLoad(const char* path, int maxVersion)
{
void* result = dlopen(path, RTLD_LAZY);
void* result = dlopen(path, FF_DLOPEN_FLAGS);
if(result != NULL || maxVersion < 0)
return result;
@@ -19,7 +32,7 @@ static void* libraryLoad(const char* path, int maxVersion)
uint32_t originalLength = pathbuf.length;
ffStrbufAppendF(&pathbuf, "%i", i);
result = dlopen(pathbuf.chars, RTLD_LAZY);
result = dlopen(pathbuf.chars, FF_DLOPEN_FLAGS);
if(result != NULL)
break;
@@ -33,7 +46,7 @@ static void* libraryLoad(const char* path, int maxVersion)
void* ffLibraryLoad(const FFstrbuf* userProvidedName, ...)
{
if(userProvidedName != NULL && userProvidedName->length > 0)
return dlopen(userProvidedName->chars, RTLD_LAZY);
return dlopen(userProvidedName->chars, FF_DLOPEN_FLAGS);
va_list defaultNames;
va_start(defaultNames, userProvidedName);
+4 -1
View File
@@ -1448,8 +1448,11 @@ int main(int argc, const char** argv)
startIndex = colonIndex + 1;
}
ffFinish(&instance);
ffStrbufDestroy(&data.structure);
ffValuestoreDestroy(&data.customValues);
ffFinish(&instance);
ffDestroyInstance(&instance);
}
+1
View File
@@ -201,6 +201,7 @@ typedef struct FFinstance
void ffInitInstance(FFinstance* instance);
void ffStart(FFinstance* instance);
void ffFinish(FFinstance* instance);
void ffDestroyInstance(FFinstance* instance);
void ffListFeatures();
+2
View File
@@ -93,6 +93,8 @@ void ffPrintSong(FFinstance* instance)
ffStrbufAppendF(&songPretty, " (%s)", media->status.chars);
ffStrbufPutTo(&songPretty, stdout);
ffStrbufDestroy(&artistPretty);
}
else
{
+1
View File
@@ -0,0 +1 @@
leak:*libwayland-client.so*