Fix a memory leak

This commit is contained in:
Adam Jackson 2018-10-16 12:43:26 -04:00
parent 5f3e6c3eef
commit 8645d0b016
2 changed files with 43 additions and 1 deletions

View File

@ -0,0 +1,37 @@
From a1e1a7b0b9a7bcededfc9166df58541675615699 Mon Sep 17 00:00:00 2001
From: Adam Jackson <ajax@redhat.com>
Date: Tue, 16 Oct 2018 12:39:26 -0400
Subject: [PATCH] Fix a memory leak on the error path in XpGetLocaleNetString
After Data() we own the pointer again, so we can just free it before
getting the reply.
Signed-off-by: Adam Jackson <ajax@redhat.com>
---
src/XpPrinter.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/XpPrinter.c b/src/XpPrinter.c
index 03b18c4..4e8cdc9 100644
--- a/src/XpPrinter.c
+++ b/src/XpPrinter.c
@@ -118,14 +118,14 @@ XpGetPrinterList (
if (req->localeLen)
Data( dpy, (char *) locale, (long) req->localeLen );
+ XFree(locale);
+
if (! _XReply (dpy, (xReply *) &rep, 0, xFalse)) {
UnlockDisplay(dpy);
SyncHandle();
return ( (XPPrinterList) NULL ); /* error */
}
- XFree(locale);
-
*list_count = rep.listCount;
if (*list_count) {
--
2.19.0

View File

@ -10,7 +10,7 @@
Summary: X.Org X11 libXp runtime library
Name: libXp
Version: 1.0.3
Release: 2%{?dist}
Release: 3%{?dist}
License: MIT
Group: System Environment/Libraries
URL: http://www.x.org
@ -25,6 +25,7 @@ BuildRequires: libXau-devel
BuildRequires: libtool automake autoconf gettext
Patch0: add-proto-files.patch
Patch1: 0001-Fix-a-memory-leak-on-the-error-path-in-XpGetLocaleNe.patch
%description
X.Org X11 libXp runtime library
@ -44,6 +45,7 @@ X.Org X11 libXp development package
%prep
%setup -q
%patch0 -p1 -b .add-proto-files
%patch1 -p1 -b .leak
%build
CPPFLAGS="$CPPFLAGS -I$RPM_BUILD_ROOT%{_includedir}"
@ -81,6 +83,9 @@ rm -f $RPM_BUILD_ROOT%{_libdir}/*.la
%{_libdir}/pkgconfig/xp.pc
%changelog
* Tue Oct 16 2018 Adam Jackson <ajax@redhat.com> - 1.0.3-3
- Fix a memory leak
* Fri Jul 13 2018 Fedora Release Engineering <releng@fedoraproject.org> - 1.0.3-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild