Merge branch 'pull-request/1439'

* pull-request/1439:
  fixed broken test
  add new error constant PREG_JIT_STACKLIMIT_ERROR
This commit is contained in:
Christoph M. Becker 2015-07-29 18:21:46 +02:00
commit 6855e2f08b
3 changed files with 21 additions and 2 deletions

View File

@ -50,7 +50,8 @@ enum {
PHP_PCRE_BACKTRACK_LIMIT_ERROR,
PHP_PCRE_RECURSION_LIMIT_ERROR,
PHP_PCRE_BAD_UTF8_ERROR,
PHP_PCRE_BAD_UTF8_OFFSET_ERROR
PHP_PCRE_BAD_UTF8_OFFSET_ERROR,
PHP_PCRE_JIT_STACKLIMIT_ERROR
};
@ -77,6 +78,12 @@ static void pcre_handle_exec_error(int pcre_code) /* {{{ */
case PCRE_ERROR_BADUTF8_OFFSET:
preg_code = PHP_PCRE_BAD_UTF8_OFFSET_ERROR;
break;
#ifdef PCRE_STUDY_JIT_COMPILE
case PCRE_ERROR_JIT_STACKLIMIT:
preg_code = PHP_PCRE_JIT_STACKLIMIT_ERROR;
break;
#endif
default:
preg_code = PHP_PCRE_INTERNAL_ERROR;
@ -169,6 +176,7 @@ static PHP_MINIT_FUNCTION(pcre)
REGISTER_LONG_CONSTANT("PREG_RECURSION_LIMIT_ERROR", PHP_PCRE_RECURSION_LIMIT_ERROR, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("PREG_BAD_UTF8_ERROR", PHP_PCRE_BAD_UTF8_ERROR, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("PREG_BAD_UTF8_OFFSET_ERROR", PHP_PCRE_BAD_UTF8_OFFSET_ERROR, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("PREG_JIT_STACKLIMIT_ERROR", PHP_PCRE_JIT_STACKLIMIT_ERROR, CONST_CS | CONST_PERSISTENT);
REGISTER_STRING_CONSTANT("PCRE_VERSION", (char *)pcre_version(), CONST_CS | CONST_PERSISTENT);
return SUCCESS;

View File

@ -0,0 +1,10 @@
--TEST--
Test preg_match() function : error conditions - jit stacklimit exhausted
--FILE--
<?php
var_dump(preg_match('/^(foo)+$/', str_repeat('foo', 8192)));
var_dump(preg_last_error() === PREG_JIT_STACKLIMIT_ERROR);
?>
--EXPECT--
bool(false)
bool(true)

View File

@ -39,7 +39,7 @@ string(%d) "Extension [ <persistent> extension #%d pcre version %d.%d.%d%a ] {
}
}
- Constants [14] {
- Constants [15] {
Constant [ integer PREG_PATTERN_ORDER ] { 1 }
Constant [ integer PREG_SET_ORDER ] { 2 }
Constant [ integer PREG_OFFSET_CAPTURE ] { 256 }
@ -53,6 +53,7 @@ string(%d) "Extension [ <persistent> extension #%d pcre version %d.%d.%d%a ] {
Constant [ integer PREG_RECURSION_LIMIT_ERROR ] { 3 }
Constant [ integer PREG_BAD_UTF8_ERROR ] { 4 }
Constant [ integer PREG_BAD_UTF8_OFFSET_ERROR ] { 5 }
Constant [ integer PREG_JIT_STACKLIMIT_ERROR ] { 6 }
Constant [ string PCRE_VERSION ] { %s }
}