Fix a memory leak with UTF-8 strings

Resolves: RHEL-96948
This commit is contained in:
Olivier Fourdan 2025-06-27 17:12:56 +02:00
parent 2804a851d1
commit a3ad8f5f5d
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: 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 <ofourdan@redhat.com> - 2.3.4-23
- Fix a memory leak with UTF-8 strings
Resolves: RHEL-96948
* Mon Jun 2 2025 Olivier Fourdan <ofourdan@redhat.com> - 2.3.4-22
- Keep drop-down menus on the same monitor as the pull-down button with
Xinerama