fixing covscan issue - memory leak

This commit is contained in:
Zdenek Dohnal 2018-12-03 13:08:59 +01:00
parent 6ad827b591
commit e56a693fd3
2 changed files with 23 additions and 1 deletions

16
libpaper-covscan.patch Normal file
View File

@ -0,0 +1,16 @@
diff --git a/lib/paper.c b/lib/paper.c
index 57db599..8817aea 100644
--- a/lib/paper.c
+++ b/lib/paper.c
@@ -211,7 +211,10 @@ PAPERSIZEVAR, fall-back to the old behaviour.
fclose(ps);
paperstr = malloc((strlen(papername) + 1) * sizeof(char));
- if (! paperstr) return 0;
+ if (! paperstr) {
+ free(papername);
+ return 0;
+ }
strcpy(paperstr, papername);
free(papername);

View File

@ -2,7 +2,7 @@
Name: libpaper
Version: 1.1.24
Release: 22%{?dist}
Release: 23%{?dist}
Summary: Library and tools for handling papersize
License: GPLv2
URL: http://packages.qa.debian.org/libp/libpaper.html
@ -12,6 +12,8 @@ Source0: http://ftp.debian.org/debian/pool/main/libp/libpaper/%{name}_%{version}
Patch2: libpaper-useglibcfallback.patch
# Memory leak
Patch3: libpaper-file-leak.patch
# memory leak found by covscan, reported to debian upstream
Patch4: libpaper-covscan.patch
# gcc is no longer in buildroot by default
BuildRequires: gcc
BuildRequires: libtool, gettext, gawk
@ -36,6 +38,7 @@ to develop applications which use libpaper.
%setup -q -n %{name}-%{version}%{nmu}
%patch2 -p1 -b .useglibcfallback
%patch3 -p1 -b .file-leak
%patch4 -p1 -b .covscan
libtoolize
%build
@ -82,6 +85,9 @@ done
%{_mandir}/man3/*
%changelog
* Mon Dec 03 2018 Zdenek Dohnal <zdohnal@redhat.com> - 1.1.24-23
- fixing covscan issue - memory leak
* Fri Jul 13 2018 Fedora Release Engineering <releng@fedoraproject.org> - 1.1.24-22
- Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild