[Pcre-svn] [707] code/trunk: Fix bug introduced at 10.21: us…

Top Page
Delete this message
Author: Subversion repository
Date:  
To: pcre-svn
Subject: [Pcre-svn] [707] code/trunk: Fix bug introduced at 10.21: use memory allocator from the pattern if no
Revision: 707
          http://www.exim.org/viewvc/pcre2?view=rev&revision=707
Author:   ph10
Date:     2017-03-25 15:19:49 +0000 (Sat, 25 Mar 2017)
Log Message:
-----------
Fix bug introduced at 10.21: use memory allocator from the pattern if no 
context is supplied to pcre2_match().


Modified Paths:
--------------
    code/trunk/ChangeLog
    code/trunk/src/pcre2_match.c


Modified: code/trunk/ChangeLog
===================================================================
--- code/trunk/ChangeLog    2017-03-25 11:52:22 UTC (rev 706)
+++ code/trunk/ChangeLog    2017-03-25 15:19:49 UTC (rev 707)
@@ -88,7 +88,11 @@
 of 10.23/36); pcre2test has been upgraded so that \=find_limits works with DFA 
 matching to find the minimum value for this limit.


+16. Since 10.21, if pcre2_match() was called with a null context, default
+memory allocation functions were used instead of whatever was used when the
+pattern was compiled.

+
Version 10.23 14-February-2017
------------------------------


Modified: code/trunk/src/pcre2_match.c
===================================================================
--- code/trunk/src/pcre2_match.c    2017-03-25 11:52:22 UTC (rev 706)
+++ code/trunk/src/pcre2_match.c    2017-03-25 15:19:49 UTC (rev 707)
@@ -6084,11 +6084,6 @@
 #undef FF
 #undef OO


-/* A NULL match context means "use a default context" */
-
-if (mcontext == NULL)
- mcontext = (pcre2_match_context *)(&PRIV(default_match_context));
-
/* These two settings are used in the code for checking a UTF string that
follows immediately afterwards. Other values in the mb block are used only
during interpretive processing, not when the JIT support is in use, so they are
@@ -6156,7 +6151,7 @@
/* It is an error to set an offset limit without setting the flag at compile
time. */

-if (mcontext->offset_limit != PCRE2_UNSET &&
+if (mcontext != NULL && mcontext->offset_limit != PCRE2_UNSET &&
      (re->overall_options & PCRE2_USE_OFFSET_LIMIT) == 0)
   return PCRE2_ERROR_BADOFFSETLIMIT;


@@ -6175,8 +6170,16 @@
}
#endif

-/* Carry on with non-JIT matching. */
+/* Carry on with non-JIT matching. A NULL match context means "use a default
+context", but we take the memory control functions from the pattern. */

+if (mcontext == NULL)
+ {
+ mcontext = (pcre2_match_context *)(&PRIV(default_match_context));
+ mb->memctl = re->memctl;
+ }
+else mb->memctl = mcontext->memctl;
+
anchored = ((re->overall_options | options) & PCRE2_ANCHORED) != 0;
firstline = (re->overall_options & PCRE2_FIRSTLINE) != 0;
startline = (re->flags & PCRE2_STARTLINE) != 0;
@@ -6187,7 +6190,6 @@

mb->callout = mcontext->callout;
mb->callout_data = mcontext->callout_data;
-mb->memctl = mcontext->memctl;

mb->start_subject = subject;
mb->start_offset = start_offset;