~sircmpwn/public-inbox

[PATCH fdicons 1/2] Fix memory leak on database destroy

Tom Lebreux
Details
Message ID
<20200221043429.1381592-1-tomlebreux@cock.li>
DKIM signature
pass
Download raw message
Patch: +30 -0
---
 src/database.c | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)

diff --git a/src/database.c b/src/database.c
index a9259be4912e..a2d053f2a9a6 100644
--- a/src/database.c
+++ b/src/database.c
@@ -377,9 +377,39 @@ fd_icon_database_add_path(struct fd_icon_database *database, const char *path)
	}
}

static void
fd_icon_theme_dir_destroy(struct fd_icon_theme_dir *directories)
{
	while (directories) {
		struct fd_icon_theme_dir *next = directories->next;
		free(directories->name);
		free(directories->context);
		free(directories);
		directories = next;
	}
}

static void
fd_icon_theme_destroy(struct fd_icon_theme *themes)
{
	while (themes) {
		struct fd_icon_theme *next = themes->next;
		fd_icon_theme_dir_destroy(themes->directories);
		free(themes->comment);
		free(themes->display_name);
		free(themes->example);
		free(themes->inherits);
		free(themes->name);
		free(themes->path);
		free(themes);
		themes = next;
	}
}

void
fd_icon_database_destroy(struct fd_icon_database *database)
{
	fd_icon_theme_destroy(database->themes);
	free(database->default_theme);
	free(database);
}
-- 
2.25.0