Fix a memory leak with UTF-8 strings

Resolves: RHEL-100816
This commit is contained in:
Olivier Fourdan 2025-06-27 17:12:56 +02:00
parent 5691de2f55
commit fa61f8a216
2 changed files with 37 additions and 1 deletions

View File

@ -0,0 +1,28 @@
From 30ff6e00e9a5edc15ff438b6cfd8a5a4169630a1 Mon Sep 17 00:00:00 2001
From: Olivier Fourdan <ofourdan@redhat.com>
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 <ofourdan@redhat.com>
---
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

View File

@ -1,7 +1,7 @@
Summary: Run-time libraries and programs
Name: motif
Version: 2.3.4
Release: 30%{?dist}
Release: 31%{?dist}
License: LGPLv2+
Source: http://downloads.sf.net/motif/motif-%{version}-src.tgz
Source1: xmbind
@ -56,6 +56,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-100816
Patch65: 0001-Xm-String-Fix-memory-leak.patch
Conflicts: lesstif <= 0.92.32-6
%description
@ -110,6 +113,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
./autogen.sh
@ -159,6 +163,10 @@ rm -f %{buildroot}%{_libdir}/*.la
%{_libdir}/lib*.a
%changelog
* Fri Jun 27 2025 Olivier Fourdan <ofourdan@redhat.com> - 2.3.4-31
- Fix a memory leak with UTF-8 strings
Resolves: RHEL-100816
* Mon Jun 2 2025 Olivier Fourdan <ofourdan@redhat.com> - 2.3.4-30
- Keep drop-down menus on the same monitor as the pull-down button with
Xinerama