From 5b6f1b481abb506f1e922dcbede42598c848901d Mon Sep 17 00:00:00 2001 From: Alx Sa Date: Mon, 9 Mar 2026 16:21:30 +0000 Subject: [PATCH] file-data: Prevent crash with GIH and empty groups Empty layer groups have no dimensions, which can cause the GIH exporter to crash when splitting cells (as it produces negative width & height dimensions). To prevent this, this patch initializes potential brushes to NULL, verifies the dimensions are positive before trying to create GimpTempBuf with then, and prevents a possible NULL brush from being added to the exported brush list. --- app/file-data/file-data-gbr.c | 5 ++++- app/file-data/file-data-gih.c | 3 ++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/app/file-data/file-data-gbr.c b/app/file-data/file-data-gbr.c index 1b30919ac1..a99b472ea0 100644 --- a/app/file-data/file-data-gbr.c +++ b/app/file-data/file-data-gbr.c @@ -275,6 +275,9 @@ file_gbr_drawable_to_brush (GimpDrawable *drawable, width = rect->width; height = rect->height; + if (width < 0 || height < 0) + return NULL; + brush = g_object_new (GIMP_TYPE_BRUSH, "name", name, "mime-type", "image/x-gimp-gbr", @@ -421,7 +424,7 @@ file_gbr_image_to_brush (GimpImage *image, const gchar *name, gdouble spacing) { - GimpBrush *brush; + GimpBrush *brush = NULL; GimpImage *subimage = NULL; GimpDrawable *drawable; gint width; diff --git a/app/file-data/file-data-gih.c b/app/file-data/file-data-gih.c index 0d9d99f29f..19dc43dc49 100644 --- a/app/file-data/file-data-gih.c +++ b/app/file-data/file-data-gih.c @@ -346,7 +346,8 @@ file_gih_image_to_pipe (GimpImage *image, gimp_object_get_name (layer), spacing); - brushes = g_list_prepend (brushes, brush); + if (brush) + brushes = g_list_prepend (brushes, brush); } } }