From 1bd3658bd903b78b6681abd588d6565304603f3f Mon Sep 17 00:00:00 2001 From: "Philip.Hazel" Date: Mon, 9 Nov 2015 17:39:43 +0000 Subject: [PATCH] Allow for the possibility of the size of the nest_save structure not being a factor of the size of the compiling workspace. --- ChangeLog | 3 +++ src/pcre2_compile.c | 9 +++++++++ 2 files changed, 12 insertions(+) diff --git a/ChangeLog b/ChangeLog index 7678e13..7c20908 100644 --- a/ChangeLog +++ b/ChangeLog @@ -272,6 +272,9 @@ size of patterns that they are prepared to handle. checking whether a group has a fixed length and/or could match an empty string, especially when recursion or subroutine calls are involved. +80. Allow for the possibility of the size of the nest_save structure not being +a factor of the size of the compiling workspace (it currently is). + Version 10.20 30-June-2015 -------------------------- diff --git a/src/pcre2_compile.c b/src/pcre2_compile.c index b82e6cb..e79e975 100644 --- a/src/pcre2_compile.c +++ b/src/pcre2_compile.c @@ -3149,6 +3149,15 @@ named_group *ng; nest_save *top_nest = NULL; nest_save *end_nests = (nest_save *)(cb->start_workspace + cb->workspace_size); +/* The size of the nest_save structure might not be a factor of the size of the +workspace. Therefore we must round down end_nests so as to correctly avoid +creating a nest_save that spans the end of the workspace. */ + +end_nests = (nest_save *)((char *)end_nests - + ((cb->workspace_size * sizeof(PCRE2_UCHAR)) % sizeof(nest_save))); + +/* Now scan the pattern */ + for (; ptr < cb->end_pattern; ptr++) { c = *ptr;