~sircmpwn/public-inbox

fdicons: Prevent crash when destroying NULL database v1 PROPOSED

Tom Lebreux
Tom Lebreux: 3
 Prevent crash when destroying NULL database
 Fix memory leak with fd_icon_database_get_icon
 Fix fd_icon_destroy leaking attach points

 3 files changed, 18 insertions(+), 2 deletions(-)
Thanks! I pushed all five of your patches:

To gitlab.freedesktop.org:ddevault/fdicons
   47d4c41..633d8b8  master -> master
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~sircmpwn/public-inbox/patches/9834/mbox | git am -3
Learn more about email & git

[PATCH fdicons 1/3] Prevent crash when destroying NULL database Export this patch

Tom Lebreux
---
 src/database.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/database.c b/src/database.c
index a2d053f2a9a6..de7ffff341d1 100644
--- a/src/database.c
+++ b/src/database.c
@@ -409,6 +409,9 @@ fd_icon_theme_destroy(struct fd_icon_theme *themes)
void
fd_icon_database_destroy(struct fd_icon_database *database)
{
	if (!database) {
		return;
	}
	fd_icon_theme_destroy(database->themes);
	free(database->default_theme);
	free(database);
-- 
2.25.0

[PATCH fdicons 2/3] Fix memory leak with fd_icon_database_get_icon Export this patch

Tom Lebreux
---
 src/lookup.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/lookup.c b/src/lookup.c
index a50033e6b11f..c7bc8eccee6e 100644
--- a/src/lookup.c
+++ b/src/lookup.c
@@ -224,7 +224,10 @@ fd_icon_database_get_icon(struct fd_icon_database *database, int size, ...)
	va_end(ap);
	criteria.names[i] = NULL;

	return fd_icon_database_get_icon_criteria(database, &criteria);
	struct fd_icon *icon =
		fd_icon_database_get_icon_criteria(database, &criteria);
	free(criteria.names);
	return icon;
}

void
-- 
2.25.0

[PATCH fdicons 3/3] Fix fd_icon_destroy leaking attach points Export this patch

Tom Lebreux
---
 src/lookup.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/src/lookup.c b/src/lookup.c
index c7bc8eccee6e..9a27a42479ac 100644
--- a/src/lookup.c
+++ b/src/lookup.c
@@ -230,6 +230,16 @@ fd_icon_database_get_icon(struct fd_icon_database *database, int size, ...)
	return icon;
}

static void
fd_icon_attach_point_destroy(struct fd_icon_attach_point *attach_points)
{
	while (attach_points) {
		struct fd_icon_attach_point *next = attach_points->next;
		free(attach_points);
		attach_points = next;
	}
}

void
fd_icon_destroy(struct fd_icon *icon)
{
@@ -239,6 +249,6 @@ fd_icon_destroy(struct fd_icon *icon)
	free(icon->path);
	free(icon->name);
	free(icon->display_name);
	/* TODO: Free the rest */
	fd_icon_attach_point_destroy(icon->attach_points);
	free(icon);
}
-- 
2.25.0
Thanks! I pushed all five of your patches:

To gitlab.freedesktop.org:ddevault/fdicons
   47d4c41..633d8b8  master -> master
View this thread in the archives