Package: release.debian.org
Severity: normal
Tags: bookworm
User: release.debian....@packages.debian.org
Usertags: pu
X-Debbugs-Cc: libmate...@packages.debian.org
Control: affects -1 + src:libmatekbd

[ Reason ]
Fix of two memleaks in the drawing code of libmatekbd's keyboard layouts.

[ Impact ]
MATE users when opening the keyboard layout UI.

[ Tests ]
Patch review + manual smoke test (MATE keyboard layout displays fine still).

[ Risks ]
Minimal.

[ Checklist ]
  [x] *all* changes are documented in the d/changelog
  [x] I reviewed all changes and I approve them
  [x] attach debdiff against the package in (old)stable
  [x] the issue is verified as fixed in unstable

[ Changes ]

+  * debian/patches:
+    + Add 0001_matekbd-keyboard-drawing-fix-memory-leak.patch and
+      0002_matekbd-keyboard-drawing-fix-memory-leak.patch. Fix two memory
+      leaks. Cherry-picked from recent upstream release v1.26.1.
+      (Closes: #1038430).

[ Other info ]
None.
diff -Nru libmatekbd-1.26.0/debian/changelog libmatekbd-1.26.0/debian/changelog
--- libmatekbd-1.26.0/debian/changelog  2021-12-10 22:11:08.000000000 +0100
+++ libmatekbd-1.26.0/debian/changelog  2023-06-18 09:09:08.000000000 +0200
@@ -1,3 +1,13 @@
+libmatekbd (1.26.0-1+deb12u1) bookworm; urgency=medium
+
+  * debian/patches:
+    + Add 0001_matekbd-keyboard-drawing-fix-memory-leak.patch and
+      0002_matekbd-keyboard-drawing-fix-memory-leak.patch. Fix two memory
+      leaks. Cherry-picked from recent upstream release v1.26.1.
+      (Closes: #1038430).
+
+ -- Mike Gabriel <sunwea...@debian.org>  Sun, 18 Jun 2023 09:09:08 +0200
+
 libmatekbd (1.26.0-1) unstable; urgency=medium
 
   [ Martin Wimpress ]
diff -Nru 
libmatekbd-1.26.0/debian/patches/0001_matekbd-keyboard-drawing-fix-memory-leak.patch
 
libmatekbd-1.26.0/debian/patches/0001_matekbd-keyboard-drawing-fix-memory-leak.patch
--- 
libmatekbd-1.26.0/debian/patches/0001_matekbd-keyboard-drawing-fix-memory-leak.patch
        1970-01-01 01:00:00.000000000 +0100
+++ 
libmatekbd-1.26.0/debian/patches/0001_matekbd-keyboard-drawing-fix-memory-leak.patch
        2023-06-18 08:36:13.000000000 +0200
@@ -0,0 +1,74 @@
+From ff9924aacd16a70816ec8acdff9b0a87a5cfd343 Mon Sep 17 00:00:00 2001
+From: rbuj <robert....@gmail.com>
+Date: Fri, 28 Jan 2022 11:26:20 +0100
+Subject: [PATCH 1/3] matekbd-keyboard-drawing: fix memory leak
+
+Signed-off-by: Mike Gabriel <mike.gabr...@das-netzwerkteam.de>
+---
+ libmatekbd/matekbd-keyboard-drawing.c | 17 ++++++++++-------
+ 1 file changed, 10 insertions(+), 7 deletions(-)
+
+diff --git a/libmatekbd/matekbd-keyboard-drawing.c 
b/libmatekbd/matekbd-keyboard-drawing.c
+index 086b2e3..e2e4842 100644
+--- a/libmatekbd/matekbd-keyboard-drawing.c
++++ b/libmatekbd/matekbd-keyboard-drawing.c
+@@ -1630,16 +1630,15 @@ alloc_render_context (MatekbdKeyboardDrawing * drawing)
+ 
+       GtkStyleContext *style_context =
+           gtk_widget_get_style_context (GTK_WIDGET (drawing));
+-      PangoFontDescription *fd = NULL;
+ 
+       gtk_style_context_get (style_context,
+                              gtk_style_context_get_state (style_context),
+-                             GTK_STYLE_PROPERTY_FONT, &fd, NULL);
++                             GTK_STYLE_PROPERTY_FONT, &context->font_desc,
++                             NULL);
+ 
+       context->layout = pango_layout_new (pangoContext);
+       pango_layout_set_ellipsize (context->layout, PANGO_ELLIPSIZE_END);
+ 
+-      context->font_desc = pango_font_description_copy (fd);
+       context->angle = 0;
+       context->scale_numerator = 1;
+       context->scale_denominator = 1;
+@@ -2446,7 +2445,7 @@ matekbd_keyboard_drawing_render (MatekbdKeyboardDrawing 
* kbdrawing,
+       GtkStyleContext *style_context =
+           gtk_widget_get_style_context (GTK_WIDGET (kbdrawing));
+       GdkRGBA dark_color;
+-      PangoFontDescription *fd = NULL;
++      PangoFontDescription *fd;
+ 
+       gtk_style_context_get_background_color (style_context,
+                                               gtk_style_context_get_state 
(style_context),
+@@ -2458,21 +2457,25 @@ matekbd_keyboard_drawing_render 
(MatekbdKeyboardDrawing * kbdrawing,
+ 
+       gtk_style_context_get (style_context,
+                              gtk_style_context_get_state (style_context),
+-                             GTK_STYLE_PROPERTY_FONT, &fd, NULL);
+-      fd = pango_font_description_copy (fd);
++                             GTK_STYLE_PROPERTY_FONT, &fd,
++                             NULL);
+ 
+       MatekbdKeyboardDrawingRenderContext context = {
+               cr,
+               kbdrawing->renderContext->angle,
+               layout,
+-              pango_font_description_copy (fd),
++              fd,
+               1, 1,
+               dark_color
+       };
+ 
+       if (!context_setup_scaling (&context, kbdrawing, width, height,
+                                   dpi_x, dpi_y))
++      {
++              pango_font_description_free (fd);
+               return FALSE;
++      }
++
+       cairo_translate (cr, x, y);
+ 
+       draw_keyboard_to_context (&context, kbdrawing);
+-- 
+2.39.2
+
diff -Nru 
libmatekbd-1.26.0/debian/patches/0002_matekbd-keyboard-drawing-fix-memory-leak.patch
 
libmatekbd-1.26.0/debian/patches/0002_matekbd-keyboard-drawing-fix-memory-leak.patch
--- 
libmatekbd-1.26.0/debian/patches/0002_matekbd-keyboard-drawing-fix-memory-leak.patch
        1970-01-01 01:00:00.000000000 +0100
+++ 
libmatekbd-1.26.0/debian/patches/0002_matekbd-keyboard-drawing-fix-memory-leak.patch
        2023-06-18 08:36:13.000000000 +0200
@@ -0,0 +1,34 @@
+From 911b118a7ddf831800e72f8b4f64b2766e99c6fc Mon Sep 17 00:00:00 2001
+From: rbuj <robert....@gmail.com>
+Date: Mon, 8 Nov 2021 14:32:54 +0100
+Subject: [PATCH 2/3] matekbd-keyboard-drawing: fix memory leak
+
+Signed-off-by: Mike Gabriel <mike.gabr...@das-netzwerkteam.de>
+---
+ libmatekbd/matekbd-keyboard-drawing.c | 3 +++
+ 1 file changed, 3 insertions(+)
+
+diff --git a/libmatekbd/matekbd-keyboard-drawing.c 
b/libmatekbd/matekbd-keyboard-drawing.c
+index e2e4842..a9aec4d 100644
+--- a/libmatekbd/matekbd-keyboard-drawing.c
++++ b/libmatekbd/matekbd-keyboard-drawing.c
+@@ -2096,6 +2096,7 @@ free_cdik (                      /*colors doodads 
indicators keys */
+       g_list_free (drawing->keyboard_items);
+       drawing->keyboard_items = NULL;
+ 
++      g_free (drawing->physical_indicators);
+       g_free (drawing->keys);
+       g_free (drawing->colors);
+ }
+@@ -2238,6 +2239,8 @@ destroy (MatekbdKeyboardDrawing * drawing)
+       if (drawing->surface != NULL) {
+               cairo_surface_destroy (drawing->surface);
+       }
++
++      free_cdik (drawing);
+ }
+ 
+ static void
+-- 
+2.39.2
+
diff -Nru libmatekbd-1.26.0/debian/patches/series 
libmatekbd-1.26.0/debian/patches/series
--- libmatekbd-1.26.0/debian/patches/series     1970-01-01 01:00:00.000000000 
+0100
+++ libmatekbd-1.26.0/debian/patches/series     2023-06-18 08:36:43.000000000 
+0200
@@ -0,0 +1,2 @@
+0001_matekbd-keyboard-drawing-fix-memory-leak.patch
+0002_matekbd-keyboard-drawing-fix-memory-leak.patch

Reply via email to