fixed memory leak

This commit is contained in:
Zdenek Dohnal 2018-03-09 17:03:46 +01:00
parent 9bc33c976a
commit 2815eb7790
4 changed files with 35 additions and 4 deletions

1
.gitignore vendored
View File

@ -2,3 +2,4 @@ libpaper_1.1.24.tar.gz
/libpaper_1.1.24+nmu1.tar.gz
/libpaper_1.1.24+nmu3.tar.gz
/libpaper_1.1.24+nmu4.tar.gz
/libpaper_1.1.24+nmu5.tar.gz

22
libpaper-file-leak.patch Normal file
View File

@ -0,0 +1,22 @@
diff -up libpaper-1.1.24+nmu5/lib/paper.c.file-leak libpaper-1.1.24+nmu5/lib/paper.c
--- libpaper-1.1.24+nmu5/lib/paper.c.file-leak 2018-03-09 16:21:01.028345956 +0100
+++ libpaper-1.1.24+nmu5/lib/paper.c 2018-03-09 16:40:57.824279357 +0100
@@ -140,7 +140,7 @@ char* systempapername(void) {
char* paperstr;
char* paperenv;
const char* paperdef;
- FILE* ps;
+ FILE* ps = NULL;
struct stat statbuf;
const struct paper* pp;
int c;
@@ -224,6 +224,9 @@ PAPERSIZEVAR, fall-back to the old behav
}
}
+ if (ps)
+ fclose(ps);
+
paperdef = defaultpapername();
paperstr = malloc((strlen(paperdef) + 1) * sizeof(char));

View File

@ -2,7 +2,7 @@
Name: libpaper
Version: 1.1.24
Release: 20%{?dist}
Release: 21%{?dist}
Summary: Library and tools for handling papersize
License: GPLv2
URL: http://packages.qa.debian.org/libp/libpaper.html
@ -10,6 +10,8 @@ Source0: http://ftp.debian.org/debian/pool/main/libp/libpaper/%{name}_%{version}
# Filed upstream as:
# http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=481213
Patch2: libpaper-useglibcfallback.patch
# Memory leak
Patch3: libpaper-file-leak.patch
# gcc is no longer in buildroot by default
BuildRequires: gcc
BuildRequires: libtool, gettext, gawk
@ -33,6 +35,7 @@ to develop applications which use libpaper.
%prep
%setup -q -n %{name}-%{version}%{nmu}
%patch2 -p1 -b .useglibcfallback
%patch3 -p1 -b .file-leak
libtoolize
%build
@ -61,11 +64,13 @@ done
%ldconfig_scriptlets
%files -f %{name}.lang
%doc COPYING ChangeLog README
%doc ChangeLog README
%license COPYING
%config(noreplace) %{_sysconfdir}/papersize
%dir %{_sysconfdir}/libpaper.d
%{_bindir}/paperconf
%{_libdir}/libpaper.so.*
%{_libdir}/libpaper.so.1.1.2
%{_libdir}/libpaper.so.1
%{_sbindir}/paperconfig
%{_mandir}/man1/*
%{_mandir}/man5/*
@ -77,6 +82,9 @@ done
%{_mandir}/man3/*
%changelog
* Fri Mar 09 2018 Zdenek Dohnal <zdohnal@redhat.com> - 1.1.24-21
- fixed memory leak
* Wed Feb 21 2018 Zdenek Dohnal <zdohnal@redhat.com> - 1.1.24-20
- gcc is no longer in buildroot by default

View File

@ -1 +1 @@
155d2e589e2f4ef163de8fbbc5d3dd1e libpaper_1.1.24+nmu4.tar.gz
SHA512 (libpaper_1.1.24+nmu5.tar.gz) = 4d20d454dd7d09dd7e84b9ccc3b0ff8d65d95e0ae3874ec41462f812882e7ead032310396801a47a32bfff112c4a9adaf2d8d3e6235a1fa6fbb853196a363c56