Fix a memory leak when allocating a JIT stack fails

This commit is contained in:
Petr Písař 2020-01-27 13:35:38 +01:00
parent 8fca0ec056
commit d7a3f4e85f
2 changed files with 40 additions and 1 deletions

View File

@ -0,0 +1,33 @@
From 73417f882ac907a182e1491ead2eecb7c5e559cc Mon Sep 17 00:00:00 2001
From: zherczeg <zherczeg@6239d852-aaf2-0410-a92c-79f79f948069>
Date: Fri, 24 Jan 2020 08:28:23 +0000
Subject: [PATCH] The JIT stack should be freed when the low-level stack
allocation fails.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
git-svn-id: svn://vcs.exim.org/pcre2/code/trunk@1207 6239d852-aaf2-0410-a92c-79f79f948069
Petr Písař: Ported to 10.34.
---
src/pcre2_jit_misc.c | 5 +++++
diff --git a/src/pcre2_jit_misc.c b/src/pcre2_jit_misc.c
index efdb055..36abdba 100644
--- a/src/pcre2_jit_misc.c
+++ b/src/pcre2_jit_misc.c
@@ -145,6 +145,11 @@ maxsize = (maxsize + STACK_GROWTH_RATE - 1) & ~(STACK_GROWTH_RATE - 1);
jit_stack = PRIV(memctl_malloc)(sizeof(pcre2_real_jit_stack), (pcre2_memctl *)gcontext);
if (jit_stack == NULL) return NULL;
jit_stack->stack = sljit_allocate_stack(startsize, maxsize, &jit_stack->memctl);
+if (jit_stack->stack == NULL)
+ {
+ jit_stack->memctl.free(jit_stack, jit_stack->memctl.memory_data);
+ return NULL;
+ }
return jit_stack;
#endif
--
2.21.1

View File

@ -9,7 +9,7 @@
#%%global rcversion RC1
Name: pcre2
Version: 10.34
Release: %{?rcversion:0.}4%{?rcversion:.%rcversion}%{?dist}
Release: %{?rcversion:0.}5%{?rcversion:.%rcversion}%{?dist}
%global myversion %{version}%{?rcversion:-%rcversion}
Summary: Perl-compatible regular expression library
# the library: BSD with exceptions
@ -60,6 +60,8 @@ Patch2: pcre2-10.34-Fix-the-too-early-access-of-the-fields-of-a-compiled.pat
# Fix a crash in JITted code when a *THEN verb is used in a lookahead assertion,
# upstream bug #2510, in upstream after 10.34
Patch3: pcre2-10.34-Fix-THEN-verbs-in-lookahead-assertions-in-JIT.patch
# Fix a memory leak when allocating a JIT stack fails, in upstream after 10.34
Patch4: pcre2-10.34-The-JIT-stack-should-be-freed-when-the-low-level-sta.patch
BuildRequires: autoconf
BuildRequires: automake
BuildRequires: coreutils
@ -141,6 +143,7 @@ Utilities demonstrating PCRE2 capabilities like pcre2grep or pcre2test.
%patch1 -p1
%patch2 -p1
%patch3 -p1
%patch4 -p1
# Because of multilib patch
libtoolize --copy --force
autoreconf -vif
@ -238,6 +241,9 @@ make %{?_smp_mflags} check VERBOSE=yes
%{_mandir}/man1/pcre2test.*
%changelog
* Mon Jan 27 2020 Petr Pisar <ppisar@redhat.com> - 10.34-5
- Fix a memory leak when allocating a JIT stack fails
* Mon Jan 13 2020 Petr Pisar <ppisar@redhat.com> - 10.34-4
- Fix a crash in JITted code when a *THEN verb is used in a lookahead assertion
(upstream bug #2510)