Revision: 398
http://vcs.pcre.org/viewvc?view=rev&revision=398
Author: ph10
Date: 2009-03-20 20:41:29 +0000 (Fri, 20 Mar 2009)
Log Message:
-----------
Fix problem with autocallout and dfa_exec.
Modified Paths:
--------------
code/trunk/ChangeLog
code/trunk/pcre_dfa_exec.c
code/trunk/testdata/testinput7
code/trunk/testdata/testoutput7
Modified: code/trunk/ChangeLog
===================================================================
--- code/trunk/ChangeLog 2009-03-20 19:40:08 UTC (rev 397)
+++ code/trunk/ChangeLog 2009-03-20 20:41:29 UTC (rev 398)
@@ -43,7 +43,7 @@
in the first alternative must satisfy the test.
9. If auto-callout was enabled in a pattern with a conditional group, PCRE
- could crash during matching.
+ could crash during matching, both with pcre_exec() and pcre_dfa_exec().
10. The PCRE_DOLLAR_ENDONLY option was not working when pcre_dfa_exec() was
used for matching.
Modified: code/trunk/pcre_dfa_exec.c
===================================================================
--- code/trunk/pcre_dfa_exec.c 2009-03-20 19:40:08 UTC (rev 397)
+++ code/trunk/pcre_dfa_exec.c 2009-03-20 20:41:29 UTC (rev 398)
@@ -61,7 +61,6 @@
#define SP " "
-
/*************************************************
* Code parameters and static tables *
*************************************************/
@@ -2205,13 +2204,14 @@
int condcode;
/* Because of the way auto-callout works during compile, a callout item
- is inserted between OP_COND and an assertion condition. */
+ is inserted between OP_COND and an assertion condition. This does not
+ happen for the other conditions. */
if (code[LINK_SIZE+1] == OP_CALLOUT)
{
+ rrc = 0;
if (pcre_callout != NULL)
{
- int rrc;
pcre_callout_block cb;
cb.version = 1; /* Version 1 of the callout block */
cb.callout_number = code[LINK_SIZE+2];
@@ -2226,11 +2226,11 @@
cb.capture_last = -1;
cb.callout_data = md->callout_data;
if ((rrc = (*pcre_callout)(&cb)) < 0) return rrc; /* Abandon */
- if (rrc == 0) { ADD_ACTIVE(state_offset + _pcre_OP_lengths[OP_CALLOUT], 0); }
}
- code += _pcre_OP_lengths[OP_CALLOUT];
+ if (rrc > 0) break; /* Fail this thread */
+ code += _pcre_OP_lengths[OP_CALLOUT]; /* Skip callout data */
}
-
+
condcode = code[LINK_SIZE+1];
/* Back reference conditions are not supported */
@@ -2240,9 +2240,7 @@
/* The DEFINE condition is always false */
if (condcode == OP_DEF)
- {
- ADD_ACTIVE(state_offset + codelink + LINK_SIZE + 1, 0);
- }
+ { ADD_ACTIVE(state_offset + codelink + LINK_SIZE + 1, 0); }
/* The only supported version of OP_RREF is for the value RREF_ANY,
which means "test if in any recursion". We can't test for specifically
@@ -2252,8 +2250,9 @@
{
int value = GET2(code, LINK_SIZE+2);
if (value != RREF_ANY) return PCRE_ERROR_DFA_UCOND;
- if (recursing > 0) { ADD_ACTIVE(state_offset + LINK_SIZE + 4, 0); }
- else { ADD_ACTIVE(state_offset + codelink + LINK_SIZE + 1, 0); }
+ if (recursing > 0)
+ { ADD_ACTIVE(state_offset + LINK_SIZE + 4, 0); }
+ else { ADD_ACTIVE(state_offset + codelink + LINK_SIZE + 1, 0); }
}
/* Otherwise, the condition is an assertion */
@@ -2281,9 +2280,7 @@
if ((rc >= 0) ==
(condcode == OP_ASSERT || condcode == OP_ASSERTBACK))
- {
- ADD_ACTIVE(endasscode + LINK_SIZE + 1 - start_code, 0);
- }
+ { ADD_ACTIVE(endasscode + LINK_SIZE + 1 - start_code, 0); }
else
{ ADD_ACTIVE(state_offset + codelink + LINK_SIZE + 1, 0); }
}
@@ -2456,7 +2453,7 @@
if ((rrc = (*pcre_callout)(&cb)) < 0) return rrc; /* Abandon */
}
if (rrc == 0)
- { ADD_ACTIVE(state_offset + _pcre_OP_lengths[OP_CALLOUT], 0); }
+ { ADD_ACTIVE(state_offset + _pcre_OP_lengths[OP_CALLOUT], 0); }
break;
Modified: code/trunk/testdata/testinput7
===================================================================
--- code/trunk/testdata/testinput7 2009-03-20 19:40:08 UTC (rev 397)
+++ code/trunk/testdata/testinput7 2009-03-20 20:41:29 UTC (rev 398)
@@ -4419,4 +4419,8 @@
ab
\C-ab
+/^"((?(?=[a])[^"])|b)*"$/C
+ "ab"
+ \C-"ab"
+
/ End of testinput7 /
Modified: code/trunk/testdata/testoutput7
===================================================================
--- code/trunk/testdata/testoutput7 2009-03-20 19:40:08 UTC (rev 397)
+++ code/trunk/testdata/testoutput7 2009-03-20 20:41:29 UTC (rev 398)
@@ -7339,4 +7339,37 @@
\C-ab
0: ab
+/^"((?(?=[a])[^"])|b)*"$/C
+ "ab"
+--->"ab"
+ +0 ^ ^
+ +1 ^ "
+ +2 ^^ ((?(?=[a])[^"])|b)*
++21 ^^ "
+ +3 ^^ (?(?=[a])[^"])
++18 ^^ b
+ +5 ^^ (?=[a])
+ +8 ^ [a]
++11 ^^ )
++12 ^^ [^"]
++16 ^ ^ )
++17 ^ ^ |
++21 ^ ^ "
+ +3 ^ ^ (?(?=[a])[^"])
++18 ^ ^ b
+ +5 ^ ^ (?=[a])
+ +8 ^ [a]
++19 ^ ^ )
++21 ^ ^ "
+ +3 ^ ^ (?(?=[a])[^"])
++18 ^ ^ b
+ +5 ^ ^ (?=[a])
+ +8 ^ [a]
++17 ^ ^ |
++22 ^ ^ $
++23 ^ ^
+ 0: "ab"
+ \C-"ab"
+ 0: "ab"
+
/ End of testinput7 /