Fix crash when more than one kind of "push" was set in pcre2test.

This commit is contained in:
Philip.Hazel 2017-05-06 16:56:07 +00:00
parent 6e943e5f47
commit 382b64b01c
4 changed files with 67 additions and 42 deletions

View File

@ -153,6 +153,9 @@ tests to improve coverage.
30. Implement (?n: for PCRE2_NO_AUTO_CAPTURE, because Perl now has this. 30. Implement (?n: for PCRE2_NO_AUTO_CAPTURE, because Perl now has this.
31. If more than one of "push", "pushcopy", or "pushtablescopy" were set in
pcre2test, a crash could occur.
Version 10.23 14-February-2017 Version 10.23 14-February-2017
------------------------------ ------------------------------

View File

@ -721,12 +721,15 @@ the first control word. Note that CTL_POSIX_NOSUB is always accompanied by
CTL_POSIX, so it doesn't need its own entries. */ CTL_POSIX, so it doesn't need its own entries. */
static uint32_t exclusive_pat_controls[] = { static uint32_t exclusive_pat_controls[] = {
CTL_POSIX | CTL_HEXPAT, CTL_POSIX | CTL_HEXPAT,
CTL_POSIX | CTL_PUSH, CTL_POSIX | CTL_PUSH,
CTL_POSIX | CTL_PUSHCOPY, CTL_POSIX | CTL_PUSHCOPY,
CTL_POSIX | CTL_PUSHTABLESCOPY, CTL_POSIX | CTL_PUSHTABLESCOPY,
CTL_POSIX | CTL_USE_LENGTH, CTL_POSIX | CTL_USE_LENGTH,
CTL_EXPAND | CTL_HEXPAT }; CTL_PUSH | CTL_PUSHCOPY,
CTL_PUSH | CTL_PUSHTABLESCOPY,
CTL_PUSHCOPY | CTL_PUSHTABLESCOPY,
CTL_EXPAND | CTL_HEXPAT };
/* Data controls that are mutually exclusive. At present these are all in the /* Data controls that are mutually exclusive. At present these are all in the
first control word. */ first control word. */

44
testdata/testinput20 vendored
View File

@ -31,20 +31,20 @@
#load testsaved2 #load testsaved2
#pop info #pop info
foofoo foofoo
barbar barbar
#pop mark #pop mark
C C
\= Expect no match \= Expect no match
D D
#pop #pop
AmanaplanacanalPanama AmanaplanacanalPanama
#pop info #pop info
metcalfe 33 metcalfe 33
# Check for an error when different tables are used. # Check for an error when different tables are used.
/abc/push,tables=1 /abc/push,tables=1
@ -59,30 +59,30 @@
#pop should give an error #pop should give an error
pqr pqr
/abcd/pushcopy /abcd/pushcopy
abcd abcd
#pop #pop
abcd abcd
#pop should give an error #pop should give an error
/abcd/push /abcd/push
#popcopy #popcopy
abcd abcd
#pop #pop
abcd abcd
/abcd/push /abcd/push
#save testsaved1 #save testsaved1
#pop should give an error #pop should give an error
#load testsaved1 #load testsaved1
#popcopy #popcopy
abcd abcd
#pop #pop
abcd abcd
@ -91,10 +91,18 @@
/abcd/pushtablescopy /abcd/pushtablescopy
abcd abcd
#popcopy #popcopy
abcd abcd
#pop #pop
abcd abcd
# Must only specify one of these
//push,pushcopy
//push,pushtablescopy
//pushcopy,pushtablescopy
# End of testinput20 # End of testinput20

47
testdata/testoutput20 vendored
View File

@ -40,25 +40,25 @@ Named capturing subpatterns:
Options: dupnames Options: dupnames
Starting code units: b f Starting code units: b f
Subject length lower bound = 6 Subject length lower bound = 6
foofoo foofoo
0: foofoo 0: foofoo
1: foo 1: foo
barbar barbar
0: barbar 0: barbar
1: <unset> 1: <unset>
2: bar 2: bar
#pop mark #pop mark
C C
0: C 0: C
1: C 1: C
MK: A MK: A
\= Expect no match \= Expect no match
D D
No match, mark = A No match, mark = A
#pop #pop
AmanaplanacanalPanama AmanaplanacanalPanama
0: AmanaplanacanalPanama 0: AmanaplanacanalPanama
1: <unset> 1: <unset>
2: <unset> 2: <unset>
@ -78,7 +78,7 @@ Subject length lower bound = 3
0: metcalfe 33 0: metcalfe 33
1: metcalfe 1: metcalfe
2: 33 2: 33
# Check for an error when different tables are used. # Check for an error when different tables are used.
/abc/push,tables=1 /abc/push,tables=1
@ -97,13 +97,13 @@ Serialization failed: error -30: patterns do not all use the same character tabl
#pop should give an error #pop should give an error
** Can't pop off an empty stack ** Can't pop off an empty stack
pqr pqr
/abcd/pushcopy /abcd/pushcopy
abcd abcd
0: abcd 0: abcd
#pop #pop
abcd abcd
0: abcd 0: abcd
#pop should give an error #pop should give an error
@ -113,21 +113,21 @@ Serialization failed: error -30: patterns do not all use the same character tabl
#popcopy #popcopy
abcd abcd
0: abcd 0: abcd
#pop #pop
abcd abcd
0: abcd 0: abcd
/abcd/push /abcd/push
#save testsaved1 #save testsaved1
#pop should give an error #pop should give an error
** Can't pop off an empty stack ** Can't pop off an empty stack
#load testsaved1 #load testsaved1
#popcopy #popcopy
abcd abcd
0: abcd 0: abcd
#pop #pop
abcd abcd
0: abcd 0: abcd
@ -139,12 +139,23 @@ Serialization failed: error -30: patterns do not all use the same character tabl
abcd abcd
0: abcd 0: abcd
#popcopy #popcopy
abcd abcd
0: abcd 0: abcd
#pop #pop
abcd abcd
0: abcd 0: abcd
# Must only specify one of these
//push,pushcopy
** Not allowed together: push pushcopy
//push,pushtablescopy
** Not allowed together: push pushtablescopy
//pushcopy,pushtablescopy
** Not allowed together: pushcopy pushtablescopy
# End of testinput20 # End of testinput20