Fix memory leaks, initialize memory

Also fix mixed use of spaces and tabs in spec.

Resolves: RHEL-42560
This commit is contained in:
Vitezslav Crhonek 2024-07-29 12:39:38 +02:00 committed by vcrhonek
parent 75acb1cedd
commit ea9f0fa8b8
2 changed files with 51 additions and 7 deletions

View File

@ -0,0 +1,38 @@
diff -up onig-6.9.9/src/regexec.c.orig onig-6.9.9/src/regexec.c
--- onig-6.9.9/src/regexec.c.orig 2022-12-12 14:27:04.000000000 +0100
+++ onig-6.9.9/src/regexec.c 2024-07-29 12:30:55.752328341 +0200
@@ -4517,6 +4517,7 @@ regset_search_body_position_lead(OnigReg
sr = (SearchRange* )xmalloc(sizeof(*sr) * n);
CHECK_NULL_RETURN_MEMERR(sr);
+ xmemset(sr, 0, sizeof(*sr) * n);
for (i = 0; i < n; i++) {
reg = set->rs[i].reg;
diff -up onig-6.9.9/src/regparse.c.orig onig-6.9.9/src/regparse.c
--- onig-6.9.9/src/regparse.c.orig 2024-07-29 12:31:07.838347726 +0200
+++ onig-6.9.9/src/regparse.c 2024-07-29 12:33:48.509582274 +0200
@@ -4190,7 +4190,10 @@ and_cclass(CClassNode* dest, CClassNode*
pbuf = tbuf;
}
}
- if (r != 0) return r;
+ if (r != 0) {
+ bbuf_free(pbuf);
+ return r;
+ }
dest->mbuf = pbuf;
bbuf_free(buf1);
@@ -4247,7 +4250,10 @@ or_cclass(CClassNode* dest, CClassNode*
pbuf = tbuf;
}
}
- if (r != 0) return r;
+ if (r != 0) {
+ bbuf_free(pbuf);
+ return r;
+ }
dest->mbuf = pbuf;
bbuf_free(buf1);

View File

@ -9,11 +9,11 @@
%endif
%if 0%{?git_snapshot}
%global gitdate 20230501
%global gitcommit 41a3b802af2155eef6d648aa3608e39605110642
%global shortcommit %(c=%{gitcommit}; echo ${c:0:7})
%global gitdate 20230501
%global gitcommit 41a3b802af2155eef6d648aa3608e39605110642
%global shortcommit %(c=%{gitcommit}; echo ${c:0:7})
%global gitversion %{gitdate}git%{shortcommit}
%global gitversion %{gitdate}git%{shortcommit}
%endif
%global mainver 6.9.9
@ -21,7 +21,7 @@
#%%global betaver rc4
#%%define prerelease 1
%global baserelease 5
%global baserelease 6
Name: oniguruma
Version: %{mainver}%{?postver:.%postver}%{?gitversion:^%{?gitversion}}
@ -33,12 +33,13 @@ License: BSD-2-Clause
URL: https://github.com/kkos/oniguruma/
Source0: https://github.com/kkos/oniguruma/releases/download/v%{mainver}%{?betaver:_%betaver}/onig-%{mainver}%{?postver:.%postver}%{?betaver:-%betaver}%{?gitversion:-%{?gitversion}}.tar.gz
Source1: create-tarball-from-git.sh
Patch0: onig-6.9.9-fix-memleaks-initialize-memory.patch
BuildRequires: make
BuildRequires: gcc
%if 0%{?git_snapshot}
BuildRequires: automake
BuildRequires: libtool
BuildRequires: automake
BuildRequires: libtool
%endif
%description
@ -59,6 +60,7 @@ developing applications that use %{name}.
%prep
%setup -q -n onig-%{mainver}%{?gitversion:-%{?gitversion}}
%autopatch -p1
%{__sed} -i.multilib -e 's|-L@libdir@||' onig-config.in
@ -124,6 +126,10 @@ autoreconf -fi
%{_libdir}/pkgconfig/%{name}.pc
%changelog
* Mon Jul 29 2024 Vitezslav Crhonek <vcrhonek@redhat.com> - 6.9.9-6
- Fix memory leaks, initialize memory
Resolves: RHEL-42560
* Wed Jul 10 2024 Vitezslav Crhonek <vcrhonek@redhat.com> - 6.9.9-5
- Enable LTO