Skip to content

Commit b0e51ba

Browse files
committed
Global: fix memleaks
1 parent b6fff0c commit b0e51ba

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
lines changed

src/detection/wmtheme/wmtheme_linux.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include "detection/gtk_qt/gtk_qt.h"
77
#include "detection/displayserver/displayserver.h"
88
#include "util/stringUtils.h"
9+
#include "util/mallocHelper.h"
910

1011
static bool detectWMThemeFromConfigFile(const char* configFile, const char* themeRegex, const char* defaultValue, FFstrbuf* themeOrError)
1112
{
@@ -91,8 +92,8 @@ static bool detectMutter(FFstrbuf* themeOrError)
9192

9293
static bool detectMuffin(FFstrbuf* themeOrError)
9394
{
94-
const char* name = ffSettingsGet("/org/cinnamon/theme/name", "org.cinnamon.theme", NULL, "name", FF_VARIANT_TYPE_STRING).strValue;
95-
const char* theme = ffSettingsGet("/org/cinnamon/desktop/wm/preferences/theme", "org.cinnamon.desktop.wm.preferences", NULL, "theme", FF_VARIANT_TYPE_STRING).strValue;
95+
FF_AUTO_FREE const char* name = ffSettingsGet("/org/cinnamon/theme/name", "org.cinnamon.theme", NULL, "name", FF_VARIANT_TYPE_STRING).strValue;
96+
FF_AUTO_FREE const char* theme = ffSettingsGet("/org/cinnamon/desktop/wm/preferences/theme", "org.cinnamon.desktop.wm.preferences", NULL, "theme", FF_VARIANT_TYPE_STRING).strValue;
9697

9798
if(name == NULL && theme == NULL)
9899
{
@@ -133,7 +134,7 @@ static bool detectXFWM4(FFstrbuf* themeOrError)
133134
static bool detectOpenbox(const FFstrbuf* dePrettyName, FFstrbuf* themeOrError)
134135
{
135136
FF_STRBUF_AUTO_DESTROY absolutePath = ffStrbufCreateA(64);
136-
const char *configFileSubpath = "openbox/rc.xml";
137+
const char *configFileSubpath = "openbox/rc.xml";
137138
if (ffStrbufIgnCaseCompS(dePrettyName, "LXQt") == 0)
138139
configFileSubpath = "openbox/lxqt-rc.xml";
139140
else if (ffStrbufIgnCaseCompS(dePrettyName, "LXDE") == 0)

src/modules/icons/icons.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ void ffPrintIcons(FFIconsOptions* options)
4040
{FF_FORMAT_ARG_TYPE_STRBUF, &result.icons2, "icons2"},
4141
}));
4242
}
43+
44+
ffStrbufDestroy(&result.icons1);
45+
ffStrbufDestroy(&result.icons2);
4346
}
4447

4548
bool ffParseIconsCommandOptions(FFIconsOptions* options, const char* key, const char* value)
@@ -94,6 +97,9 @@ void ffGenerateIconsJsonResult(FF_MAYBE_UNUSED FFIconsOptions* options, yyjson_m
9497
yyjson_mut_val* icons = yyjson_mut_obj_add_obj(doc, module, "result");
9598
yyjson_mut_obj_add_strbuf(doc, icons, "icons1", &result.icons1);
9699
yyjson_mut_obj_add_strbuf(doc, icons, "icons2", &result.icons2);
100+
101+
ffStrbufDestroy(&result.icons1);
102+
ffStrbufDestroy(&result.icons2);
97103
}
98104

99105
void ffPrintIconsHelpFormat(void)

src/modules/theme/theme.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ void ffPrintTheme(FFThemeOptions* options)
4040
{FF_FORMAT_ARG_TYPE_STRBUF, &result.theme2, "theme2"},
4141
}));
4242
}
43+
44+
ffStrbufDestroy(&result.theme1);
45+
ffStrbufDestroy(&result.theme2);
4346
}
4447

4548
bool ffParseThemeCommandOptions(FFThemeOptions* options, const char* key, const char* value)
@@ -94,6 +97,9 @@ void ffGenerateThemeJsonResult(FF_MAYBE_UNUSED FFThemeOptions* options, yyjson_m
9497
yyjson_mut_val* theme = yyjson_mut_obj_add_obj(doc, module, "result");
9598
yyjson_mut_obj_add_strbuf(doc, theme, "theme1", &result.theme1);
9699
yyjson_mut_obj_add_strbuf(doc, theme, "theme2", &result.theme2);
100+
101+
ffStrbufDestroy(&result.theme1);
102+
ffStrbufDestroy(&result.theme2);
97103
}
98104

99105
void ffPrintThemeHelpFormat(void)

0 commit comments

Comments
 (0)