On Thu, 10 Dec 2009, Rene wrote:
> when I used some kind of regexs just like "(?i)a(?-i)b|c",
> "(?i)ab(?-i)|c" et., PCRE crashed with errorcode 23 in pcre_compile.
> It seems that if the regex has some modifier( i,m,s...) at the
> beginning, and the opposite modifier appears in the first branch, then
> this error happens. I have tried PCRE 7.8/7.9/8.0, the same result...
>
> looking forward to your response, thanks:)
The patch below, for 8.00, fixes this bug. Thank you for your report.
Philip
--
Philip Hazel
===================================================================
--- pcre_compile.c (revision 461)
+++ pcre_compile.c (working copy)
@@ -5248,7 +5248,7 @@
{
cd->external_options = newoptions;
}
- else
+ else
{
if ((options & PCRE_IMS) != (newoptions & PCRE_IMS))
{
@@ -5783,6 +5783,7 @@
int length;
int orig_bracount;
int max_bracount;
+int old_external_options = cd->external_options;
branch_chain bc;
bc.outer = bcptr;
@@ -5859,6 +5860,15 @@
return FALSE;
}
+ /* If the external options have changed during this branch, it means that we
+ are at the top level, and a leading option setting has been encountered. We
+ need to re-set the original option values to take account of this so that,
+ during the pre-compile phase, we know to allow for a re-set at the start of
+ subsequent branches. */
+
+ if (old_external_options != cd->external_options)
+ oldims = cd->external_options & PCRE_IMS;
+
/* Keep the highest bracket count in case (?| was used and some branch
has fewer than the rest. */
@@ -5969,7 +5979,7 @@
PUT(code, 1, code - start_bracket);
code += 1 + LINK_SIZE;
- /* Resetting option if needed */
+ /* Reset options if needed. */
if ((options & PCRE_IMS) != oldims && *ptr == CHAR_RIGHT_PARENTHESIS)
{