From a3ad8f5f5d5fd81f222748cc365989f5ce6a923d Mon Sep 17 00:00:00 2001 From: Olivier Fourdan Date: Fri, 27 Jun 2025 17:12:56 +0200 Subject: [PATCH] Fix a memory leak with UTF-8 strings Resolves: RHEL-96948 --- 0001-Xm-String-Fix-memory-leak.patch | 28 ++++++++++++++++++++++++++++ motif.spec | 10 +++++++++- 2 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 0001-Xm-String-Fix-memory-leak.patch diff --git a/0001-Xm-String-Fix-memory-leak.patch b/0001-Xm-String-Fix-memory-leak.patch new file mode 100644 index 0000000..45a9143 --- /dev/null +++ b/0001-Xm-String-Fix-memory-leak.patch @@ -0,0 +1,28 @@ +From 30ff6e00e9a5edc15ff438b6cfd8a5a4169630a1 Mon Sep 17 00:00:00 2001 +From: Olivier Fourdan +Date: Mon, 16 Jun 2025 14:49:55 +0200 +Subject: [PATCH] Xm/String: Fix memory leak + +ComputeMetrics() would leak the string created by _XmUtf8ToUcs2(), make +sure to free the string once done with it. + +Signed-off-by: Olivier Fourdan +--- + lib/Xm/XmString.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/lib/Xm/XmString.c b/lib/Xm/XmString.c +index 2c54ef57..6ee1c40e 100644 +--- a/lib/Xm/XmString.c ++++ b/lib/Xm/XmString.c +@@ -6272,6 +6272,7 @@ ComputeMetrics(XmRendition rend, + + XTextExtents16(font_struct, str, str_len, + &dir, &asc, &desc, &char_ret); ++ XFree(str); + } else + XTextExtents16(font_struct, + (XChar2b *)text, Half(byte_count), +-- +2.50.0 + diff --git a/motif.spec b/motif.spec index d34860e..3817f94 100644 --- a/motif.spec +++ b/motif.spec @@ -1,7 +1,7 @@ Summary: Run-time libraries and programs Name: motif Version: 2.3.4 -Release: 22%{?dist} +Release: 23%{?dist} License: LGPLv2+ Group: System Environment/Libraries Source: http://downloads.sf.net/motif/motif-%{version}-src.tgz @@ -55,6 +55,9 @@ Patch62: 0005-Xm-RCMenu-Use-Xinerama-for-placement.patch Patch63: 0006-Xm-Tooltip-Use-Xinerama-for-placement.patch Patch64: 0007-Xm-ComboBox-Use-Xinerama-for-placement.patch +# https://issues.redhat.com/browse/RHEL-96948 +Patch65: 0001-Xm-String-Fix-memory-leak.patch + Conflicts: lesstif <= 0.92.32-6 %description @@ -112,6 +115,7 @@ This package contains the static Motif libraries. %patch62 -p1 -b .xinerama %patch63 -p1 -b .xinerama %patch64 -p1 -b .xinerama +%patch65 -p1 -b .memleak %build CFLAGS="$RPM_OPT_FLAGS -D_FILE_OFFSET_BITS=64" \ @@ -169,6 +173,10 @@ rm -rf %{buildroot} %{_libdir}/lib*.a %changelog +* Fri Jun 27 2025 Olivier Fourdan - 2.3.4-23 +- Fix a memory leak with UTF-8 strings + Resolves: RHEL-96948 + * Mon Jun 2 2025 Olivier Fourdan - 2.3.4-22 - Keep drop-down menus on the same monitor as the pull-down button with Xinerama