Compare commits

..
11 Commits
Author SHA1 Message Date
Alexander Kurilo 52ace952a1 Regenerate certificates for openssl tests
(cherry picked from commit 0382e761d7)
2018-12-04 11:42:42 +01:00
Christoph M. Becker 3cafea6901 Update version for PHP 7.3.0 2018-12-04 11:30:22 +01:00
Christoph M. Becker 360efc59e6 Update NEWS regarding latest bug fixes 2018-12-04 11:25:49 +01:00
Stanislav Malyshev f7275963cd Fix null pointer deref in qprint-encode filter (bug #77231)
(cherry picked from commit 36534afd10)
2018-12-04 11:09:04 +01:00
Stanislav Malyshev 648fc1e369 Fix #77020: null pointer dereference in imap_mail
If an empty $message is passed to imap_mail(), we must not set message
to NULL, since _php_imap_mail() is not supposed to handle NULL pointers
(opposed to pointers to NUL).

(cherry picked from commit 7edc639b9f)
2018-12-03 14:58:14 +01:00
Stanislav Malyshev d8b25b34a2 Fix bug #77143 - add more checks to buffer reads
(cherry picked from commit 54212674b9)
2018-12-03 14:53:02 +01:00
Stanislav Malyshev 0f658b38e8 Fix bug #77022 - use file mode or umask for new files
(cherry picked from commit 69f5e7992b)
(cherry picked from commit 2fba1e2f59)
2018-12-03 14:46:39 +01:00
Derick Rethans ea302f8b08 Fixed bug #77097 (DateTime::diff gives wrong diff when the actual diff is less than 1 second)
(cherry picked from commit dd48f0899d)
2018-12-03 14:39:39 +01:00
Stanislav Malyshev 3a144d3f7f Disable rsh/ssh functionality in imap by default (bug #77153)
(cherry picked from commit 05782f01f5)
(cherry picked from commit 3f165e8ca3)
2018-12-03 14:36:45 +01:00
Christoph M. Becker bf36d811f1 [ci skip] Prepare NEWS for 7.3 GA 2018-12-03 14:22:30 +01:00
Christoph M. Becker 69895e8ab3 Update version for PHP 7.3.0RC6 2018-11-20 11:50:34 +00:00
1113 changed files with 211702 additions and 253774 deletions

No files matched your search

+1 -1
View File
@@ -16,7 +16,7 @@ environment:
PHP_BUILD_CACHE_BASE_DIR: c:\build-cache
PHP_BUILD_OBJ_DIR: c:\obj
PHP_BUILD_CACHE_SDK_DIR: c:\build-cache\sdk
PHP_BUILD_SDK_BRANCH: php-sdk-2.2.0
PHP_BUILD_SDK_BRANCH: php-sdk-2.1.9beta1
PHP_BUILD_CRT: vc15
# ext and env setup for tests
#MYSQL_TEST_PASSWD: Password12!
+19 -18
View File
@@ -1,34 +1,35 @@
# https://editorconfig.org/
# http://editorconfig.org/
root = true
[*]
trim_trailing_whitespace = true
insert_final_newline = true
end_of_line = lf
[*.{c,h,awk,w32,bat,mk,frag}]
charset = utf-8
tab_width = 4
[{*.{awk,bat,c,cpp,d,h,l,mk,re,skl,w32,y},Makefile*}]
end_of_line = lf
indent_size = 4
indent_style = tab
tab_width = 4
trim_trailing_whitespace = true
insert_final_newline = true
[*.{dtd,html,inc,php,phpt,rng,wsdl,xml,xsd,xsl}]
[*.{php,phpt}]
charset = utf-8
end_of_line = lf
indent_size = 4
indent_style = space
trim_trailing_whitespace = true
insert_final_newline = true
[*.{ac,m4,sh,yml}]
[*.{yml,m4,sh}]
charset = utf-8
end_of_line = lf
indent_size = 2
indent_style = space
trim_trailing_whitespace = true
insert_final_newline = true
[*.md]
charset = utf-8
end_of_line = lf
indent_style = space
max_line_length = 80
[COMMIT_EDITMSG]
indent_size = 4
indent_style = space
max_line_length = 80
[*.patch]
trim_trailing_whitespace = false
insert_final_newline = true
+1 -5
View File
@@ -1,6 +1,3 @@
git:
quiet: true
dist: trusty
language: c
sudo: required
@@ -67,8 +64,7 @@ before_script:
# Run PHPs run-tests.php
script:
- ./sapi/cli/php run-tests.php -P -d extension=`pwd`/modules/zend_test.so $(if [ $ENABLE_DEBUG == 0 ]; then echo "-d opcache.enable_cli=1 -d zend_extension=`pwd`/modules/opcache.so"; fi) -g "FAIL,XFAIL,BORK,WARN,LEAK,SKIP" --offline --show-diff --show-slow 1000 --set-timeout 120
- sapi/cli/php -d extension_dir=`pwd`/modules -r 'dl("zend_test");'
- ./sapi/cli/php run-tests.php -p `pwd`/sapi/cli/php $(if [ $ENABLE_DEBUG == 0 ]; then echo "-d opcache.enable_cli=1 -d zend_extension=`pwd`/modules/opcache.so"; fi) -g "FAIL,XFAIL,BORK,WARN,LEAK,SKIP" --offline --show-diff --show-slow 1000 --set-timeout 120
after_success:
- ccache --show-stats
-1
View File
@@ -387,7 +387,6 @@ SINCE: 5.5.0
EXTENSION: openssl
PRIMARY MAINTAINER: Wez Furlong <wez@php.net> (2001 - 2006)
Pierre-Alain Joye <pajoye@php.net> (2006 - 2011)
Jakub Zelenka <bukka@php.net> (2015 - 2019)
MAINTENANCE: Maintained
STATUS: Working
SINCE: 4.0.4
+33 -1158
View File
File diff suppressed because it is too large. Load diff
+6
View File
@@ -167,7 +167,13 @@ TSRM_API const char *tsrm_api_name(void);
#define TSRMG_BULK_STATIC(id, type) ((type) (*((void ***) TSRMLS_CACHE))[TSRM_UNSHUFFLE_RSRC_ID(id)])
#define TSRMLS_CACHE_EXTERN() extern TSRM_TLS void *TSRMLS_CACHE;
#define TSRMLS_CACHE_DEFINE() TSRM_TLS void *TSRMLS_CACHE = NULL;
#if ZEND_DEBUG
#define TSRMLS_CACHE_UPDATE() TSRMLS_CACHE = tsrm_get_ls_cache()
#define TSRMLS_CACHE_RESET()
#else
#define TSRMLS_CACHE_UPDATE() if (!TSRMLS_CACHE) TSRMLS_CACHE = tsrm_get_ls_cache()
#define TSRMLS_CACHE_RESET() TSRMLS_CACHE = NULL
#endif
#define TSRMLS_CACHE _tsrm_ls_cache
/* BC only */
+9 -17
View File
@@ -616,16 +616,14 @@ TSRM_API int shmget(key_t key, size_t size, int flags)
{/*{{{*/
shm_pair *shm;
char shm_segment[26], shm_info[29];
HANDLE shm_handle = NULL, info_handle = NULL;
HANDLE shm_handle, info_handle;
BOOL created = FALSE;
if (key != IPC_PRIVATE) {
snprintf(shm_segment, sizeof(shm_segment), "TSRM_SHM_SEGMENT:%d", key);
snprintf(shm_info, sizeof(shm_info), "TSRM_SHM_DESCRIPTOR:%d", key);
snprintf(shm_segment, sizeof(shm_segment), "TSRM_SHM_SEGMENT:%d", key);
snprintf(shm_info, sizeof(shm_info), "TSRM_SHM_DESCRIPTOR:%d", key);
shm_handle = OpenFileMapping(FILE_MAP_ALL_ACCESS, FALSE, shm_segment);
info_handle = OpenFileMapping(FILE_MAP_ALL_ACCESS, FALSE, shm_info);
}
shm_handle = OpenFileMapping(FILE_MAP_ALL_ACCESS, FALSE, shm_segment);
info_handle = OpenFileMapping(FILE_MAP_ALL_ACCESS, FALSE, shm_info);
if (!shm_handle && !info_handle) {
if (flags & IPC_CREAT) {
@@ -636,8 +634,8 @@ TSRM_API int shmget(key_t key, size_t size, int flags)
DWORD high = 0;
DWORD low = size;
#endif
shm_handle = CreateFileMapping(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, high, low, key == IPC_PRIVATE ? NULL : shm_segment);
info_handle = CreateFileMapping(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0, sizeof(shm->descriptor), key == IPC_PRIVATE ? NULL : shm_info);
shm_handle = CreateFileMapping(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, high, low, shm_segment);
info_handle = CreateFileMapping(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0, sizeof(shm->descriptor), shm_info);
created = TRUE;
}
if (!shm_handle || !info_handle) {
@@ -723,7 +721,6 @@ TSRM_API void *shmat(int key, const void *shmaddr, int flags)
TSRM_API int shmdt(const void *shmaddr)
{/*{{{*/
shm_pair *shm = shm_get(0, (void*)shmaddr);
int ret;
if (!shm->segment) {
return -1;
@@ -733,12 +730,7 @@ TSRM_API int shmdt(const void *shmaddr)
shm->descriptor->shm_lpid = getpid();
shm->descriptor->shm_nattch--;
ret = UnmapViewOfFile(shm->addr) ? 0 : -1;
if (!ret && shm->descriptor->shm_nattch <= 0) {
ret = UnmapViewOfFile(shm->descriptor) ? 0 : -1;
shm->descriptor = NULL;
}
return ret;
return UnmapViewOfFile(shm->addr) ? 0 : -1;
}/*}}}*/
TSRM_API int shmctl(int key, int cmd, struct shmid_ds *buf)
@@ -778,7 +770,7 @@ static zend_always_inline void UnixTimeToFileTime(time_t t, LPFILETIME pft) /* {
// Note that LONGLONG is a 64-bit value
LONGLONG ll;
ll = t * 10000000LL + 116444736000000000LL;
ll = Int32x32To64(t, 10000000) + 116444736000000000;
pft->dwLowDateTime = (DWORD)ll;
pft->dwHighDateTime = ll >> 32;
}
+6 -124
View File
@@ -53,7 +53,7 @@ Core:
case "baz":
continue;
// Warning: "continue" targeting switch is equivalent to
// "break". Did you mean to use "continue 2"?
"break". Did you mean to use "continue 2"?
}
}
@@ -112,18 +112,6 @@ BCMath:
. bcmul() and bcpow() now return numbers with the requested scale. Formerly,
the returned numbers may have omitted trailing decimal zeroes.
DOM:
. As of PHP 7.3.16, the value of the $childNodes property of DOMDocument,
DOMNode, DOMProcessingInstruction, DOMComment, DOMText, DOMCdataSection and
DOMNotation is now an empty DOMNodeList instead of NULL, according to the
W3C and WHATWG standards and the PHP manual.
IMAP:
rsh/ssh logins are disabled by default. Use imap.enable_insecure_rsh if you want
to enable them. Note that the IMAP library does not filter mailbox names before
passing them to rsh/ssh command, thus passing untrusted data to this function
with rsh/ssh enabled is insecure.
MBString:
. Due to added support for named captures, mb_ereg_*() patterns using named
captures will behave differently. In particular named captures will be part
@@ -257,10 +245,6 @@ Standard:
PHP be linked against libargon2 reference library >= 20161029.
(RFC: https://wiki.php.net/rfc/argon2_password_hash_enhancements).
LDAP:
. Full support for LDAP Controls has been added to LDAP querying functions
and ldap_parse_result
========================================
3. Changes in SAPI modules
========================================
@@ -270,19 +254,7 @@ phpdbg:
PHPDBG_FUNC have been removed.
FPM:
. A new global option log_limit has been added. It can be used for setting
log limit for logged line which allows to log messages longer than 1024
characters without wrapping. It also fixes various wrapping issues.
. A new global option log_buffering has been added. It allows an experimental
logging without extra buffering.
. A new pool option decorate_workers_output has been added. It allows
disabling output decoration for workers output when catch_workers_output
enabled.
. The getallheaders() function is now also available.
. In PHP 7.3.11 a new pool option
request_terminate_timeout_track_finished has been added. When enabled,
request_terminate_timeout will also apply after fastcgi_finish_request()
has been called, as well as during execution of shutdown functions.
========================================
4. Deprecated Functionality
@@ -337,7 +309,7 @@ Standard:
. Passing a non-string needle to string search functions is deprecated. In the
future the needle will be interpreted as a string instead of an ASCII codepoint.
Depending on the intended behavior, you should either explicitly cast the
needle to string or perform an explicit call to chr(). The following functions
needle to string or perform an explicit call to ord(). The following functions
are affected:
. strpos()
. strrpos()
@@ -383,16 +355,6 @@ Standard:
PCRE:
. preg_quote() now also escapes the '#' character.
LDAP:
. Added a serverctrls parameter to send controls to the server in ldap_add,
ldap_mod_replace, ldap_mod_add, ldap_mod_del, ldap_rename,
ldap_compare, ldap_delete, ldap_modify_batch,
ldap_search, ldap_list, ldap_read
. Added an out parameter to get controls from the server in ldap_parse_result
. Fixed support for LDAP_OPT_SERVER_CONTROLS and LDAP_OPT_CLIENT_CONTROLS in
ldap_get_option and ldap_set_option.
========================================
6. New Functions
========================================
@@ -407,10 +369,6 @@ Core:
are available under Linux, FreeBSD, Windows, Mac, SunOS, AIX and their
derivatives. If no required timers are provided by a corresponding
platform, the function returns false.
. Added net_get_interfaces() to retrieve an array of available network
interfaces including several details.
. Added the gc_status() function to retrieve status information regarding the
cyclic GC.
Date:
. Added the DateTime::createFromImmutable() method, which mirrors
@@ -440,10 +398,6 @@ Intl:
. Added Normalizer::getRawDecomposition() and normalizer_get_raw_decomposition(),
to retrieve the Decomposition_Mapping property of a character.
LDAP:
. Added ldap_exop_refresh() to conveniently perform a Refresh extended
operation.
OpenSSL:
. Added openssl_pkey_derive that derives a shared secret for DH, ECDH and
possibly other future algorithms supported by EVP_PKEY_derive.
@@ -471,13 +425,6 @@ Standard:
last key of an array, respectively.
(RFC: <https://wiki.php.net/rfc/array_key_first_last>)
LDAP:
. Added functions ldap_add_ext, ldap_bind_ext, ldap_delete_ext, ldap_mod_add_ext,
ldap_mod_replace_ext, ldap_mod_del_ext, ldap_rename_ext
which gives access to the result object to be able to parse it
with ldap_parse_result and get more information than just success/failure.
========================================
7. New Classes and Interfaces
========================================
@@ -496,19 +443,13 @@ JSON:
Curl:
. libcurl >= 7.15.5 is now required.
DBA:
. As of PHP 7.3.14, dba_open() accepts a fifth optional parameter for lmdb
databases which allows to specify the mapsize. The parameter defaults to
zero, in which case the compiled in default mapsize (usually 1048576) will
be used. The mapsize should be a multiple of the page size of the OS.
Filter:
. FILTER_VALIDATE_FLOAT now also supports a `thousand` option, which
defines the set of allowed thousand separator chars. The default (`"',."`)
is fully backward compatible with former PHP versions.
. FILTER_SANITIZE_ADD_SLASHES has been added as an alias of the 'magic_quotes'
filter (FILTER_SANITIZE_MAGIC_QUOTES). The 'magic_quotes' filter is subject
to removal in future versions of PHP.
to removal in future versions of PHP.
FTP:
. Set default transfer mode to binary
@@ -530,22 +471,12 @@ JSON:
related constants for possible TLS protocol values have been added.
See <https://github.com/php/php-src/pull/3317>.
PCRE:
PCRE:
. The PCRE extension has been upgraded to PCRE2, which may cause minor
behavioral changes (for instance, character ranges in classes are now more
strictly interpreted), and augments the existing regular expression syntax.
See <https://wiki.php.net/rfc/pcre2-migration> for details.
PDO_DBLIB:
. Added the attribute PDO::DBLIB_ATTR_SKIP_EMPTY_ROWSETS to enable automatic
skipping of empty rowsets.
. Exposed the TDS version via the PDO::DBLIB_ATTR_TDS_VERSION attribute.
. DATETIME2 columns are now treated like DATETIME columns.
PDO_SQLite:
. SQLite3 databases can now be opened in read-only mode by setting the
new PDO::SQLITE_ATTR_OPEN_FLAGS attribute to PDO::SQLITE_READONLY.
Standard:
. var_export() now exports stdClass objects as an array casted to an object
(`(object) array( ... )`), rather than using the nonexistent method
@@ -565,10 +496,6 @@ JSON:
. Building against the bundled libzip is discouraged, but still possible by
adding `--without-libzip` to the configuration.
zlib:
. Added the zlib/level context option for the compress.zlib wrapper to
facilitate setting the desired compression level.
========================================
10. New Global Constants
========================================
@@ -638,37 +565,27 @@ Curl:
. CURL_SSLVERSION_MAX_TLSv1_2
. CURL_SSLVERSION_MAX_TLSv1_3
. CURL_SSLVERSION_TLSv1_3
. CURL_VERSION_ALTSVC
. CURL_VERSION_ASYNCHDNS
. CURL_VERSION_BROTLI
. CURL_VERSION_CONV
. CURL_VERSION_CURLDEBUG
. CURL_VERSION_DEBUG
. CURL_VERSION_GSSAPI
. CURL_VERSION_GSSNEGOTIATE
. CURL_VERSION_HTTPS_PROXY
. CURL_VERSION_IDN
. CURL_VERSION_KERBEROS5
. CURL_VERSION_LARGEFILE
. CURL_VERSION_MULTI_SSL
. CURL_VERSION_NTLM
. CURL_VERSION_NTLM_WB
. CURL_VERSION_PSL
. CURL_VERSION_SPNEGO
. CURL_VERSION_SSPI
. CURL_VERSION_TLSAUTH_SRP
Filter:
. FILTER_SANITIZE_ADD_SLASHES
. CURL_VERSION_UNIX_SOCKETS
JSON:
. JSON_THROW_ON_ERROR
OpenSSL:
. STREAM_CRYPTO_PROTO_SSLv3
. STREAM_CRYPTO_PROTO_TLSv1_0
. STREAM_CRYPTO_PROTO_TLSv1_1
. STREAM_CRYPTO_PROTO_TLSv1_2
MBString:
. MB_CASE_FOLD
. MB_CASE_LOWER_SIMPLE
@@ -689,34 +606,6 @@ PGSQL:
Standard:
. PASSWORD_ARGON2ID
LDAP:
. LDAP_CONTROL_MANAGEDSAIT
. LDAP_CONTROL_PROXY_AUTHZ
. LDAP_CONTROL_SUBENTRIES
. LDAP_CONTROL_VALUESRETURNFILTER
. LDAP_CONTROL_ASSERT
. LDAP_CONTROL_PRE_READ
. LDAP_CONTROL_POST_READ
. LDAP_CONTROL_SORTREQUEST
. LDAP_CONTROL_SORTRESPONSE
. LDAP_CONTROL_PAGEDRESULTS
. LDAP_CONTROL_AUTHZID_REQUEST
. LDAP_CONTROL_AUTHZID_RESPONSE
. LDAP_CONTROL_SYNC
. LDAP_CONTROL_SYNC_STATE
. LDAP_CONTROL_SYNC_DONE
. LDAP_CONTROL_DONTUSECOPY
. LDAP_CONTROL_PASSWORDPOLICYREQUEST
. LDAP_CONTROL_PASSWORDPOLICYRESPONSE
. LDAP_CONTROL_X_INCREMENTAL_VALUES
. LDAP_CONTROL_X_DOMAIN_SCOPE
. LDAP_CONTROL_X_PERMISSIVE_MODIFY
. LDAP_CONTROL_X_SEARCH_OPTIONS
. LDAP_CONTROL_X_TREE_DELETE
. LDAP_CONTROL_X_EXTENDED_DN
. LDAP_CONTROL_VLVREQUEST
. LDAP_CONTROL_VLVRESPONSE
========================================
11. Changes to INI File Handling
========================================
@@ -746,10 +635,6 @@ LDAP:
. New INI to set syslog ident string which is prepended to every message. It
is used only when error_log is set syslog.
- mbstring.regex_stack_limit
. New INI directive (since 7.3.5) limiting stack depth of mbstring/oniguruma
regular expressions.
========================================
12. Windows Support
========================================
@@ -764,6 +649,3 @@ LDAP:
========================================
13. Other Changes
========================================
. The cyclic GC has been enhanced, which may result in considerable performance
improvements.
+2 -6
View File
@@ -94,7 +94,7 @@ L0:
}
}));
assert(0 && ($a = function &(?array &$a, X $b = null) use ($c,&$d) : X {
assert(0 && ($a = function &(array &$a, X $b = null) use ($c,&$d) : X {
class A {
use T1, T2 {
T1::foo insteadof foo;
@@ -140,7 +140,6 @@ assert(0 && ($a = function () {
if ($a) {
} elseif ($b) {
}
if ($a); else;
}));
?>
@@ -244,7 +243,7 @@ Warning: assert(): assert(0 && ($a = function &(array &$a, X $b = null) use($c,
})) failed in %sexpect_015.php on line %d
Warning: assert(): assert(0 && ($a = function &(?array &$a, X $b = null) use($c, &$d): X {
Warning: assert(): assert(0 && ($a = function &(array &$a, X $b = null) use($c, &$d): X {
class A {
use T1, T2 {
T1::foo insteadof foo;
@@ -293,7 +292,4 @@ Warning: assert(): assert(0 && ($a = function () {
if ($a) {
} elseif ($b) {
}
if ($a) {
} else {
}
})) failed in %sexpect_015.php on line %d
-17
View File
@@ -1,17 +0,0 @@
--TEST--
AST pretty-printer
--INI--
zend.assertions=1
assert.exception=0
--FILE--
<?php
assert(0 && ($a = function () {
$var = 'test';
$str = "$var, $var[1], {$var}[], {$var[1]}[], ${var}[], ${var[1]}[]";
}));
?>
--EXPECTF--
Warning: assert(): assert(0 && ($a = function () {
$var = 'test';
$str = "$var, {$var[1]}, {$var}[], {$var[1]}[], {$var}[], {$var[1]}[]";
})) failed in %sexpect_020.php on line %d
+3 -2
View File
@@ -25,8 +25,9 @@ try {
--EXPECTF--
1. Exception: aaa in %sbug52361.php:5
Stack trace:
#0 %sbug52361.php(16): aaa->__destruct()
#1 {main}
#0 %sbug52361.php(13): aaa->__destruct()
#1 %sbug52361.php(16): bbb()
#2 {main}
2. Exception: bbb in %sbug52361.php:13
Stack trace:
#0 %sbug52361.php(16): bbb()
-7
View File
@@ -45,13 +45,6 @@ elseif (PHP_OS == 'FreeBSD') {
if ($freeMemory < 2100*1024*1024) {
die('skip Not enough memory.');
}
} elseif (PHP_OS == "WINNT") {
$s = trim(shell_exec("wmic OS get FreeVirtualMemory /Value 2>nul"));
$freeMemory = explode('=', $s)[1]*1;
if ($freeMemory < 2.1*1024*1024) {
die('skip Not enough memory.');
}
}
?>
--INI--
-29
View File
@@ -1,29 +0,0 @@
--TEST--
Bug #63206 Fully support error_handler stacking, even inside the error_handler
--FILE--
<?php
set_error_handler(function() {
echo 'First handler' . PHP_EOL;
});
set_error_handler(function() {
echo 'Second handler' . PHP_EOL;
set_error_handler(function() {
echo 'Internal handler' . PHP_EOL;
});
$triggerInternalNotice++; // warnings while handling the error should go into internal handler
restore_error_handler();
});
$triggerNotice1++;
$triggerNotice2++;
?>
--EXPECTF--
Second handler
Internal handler
Second handler
Internal handler
-26
View File
@@ -1,26 +0,0 @@
--TEST--
Bug #63206 Fully support error_handler stacking, even with null
--FILE--
<?php
set_error_handler(function() {
echo 'First handler' . PHP_EOL;
});
set_error_handler(function() {
echo 'Second handler' . PHP_EOL;
});
set_error_handler(null);
set_error_handler(function() {
echo 'Fourth handler' . PHP_EOL;
});
restore_error_handler();
restore_error_handler();
$triggerNotice++;
?>
--EXPECTF--
Second handler
-26
View File
@@ -1,26 +0,0 @@
--TEST--
Bug #63206 Fully support exception_handler stacking, even with null
--FILE--
<?php
set_exception_handler(function() {
echo 'First handler' . PHP_EOL;
});
set_exception_handler(function() {
echo 'Second handler' . PHP_EOL;
});
set_exception_handler(null);
set_exception_handler(function() {
echo 'Fourth handler' . PHP_EOL;
});
restore_exception_handler();
restore_exception_handler();
throw new Exception();
?>
--EXPECTF--
Second handler
-15
View File
@@ -1,15 +0,0 @@
--TEST--
Bug #75426: "Cannot use empty array elements" reports wrong position
--FILE--
<?php
$a = [
1,
2,
3,
,
5,
6,
];
?>
--EXPECTF--
Fatal error: Cannot use empty array elements in arrays in %s on line 5
-68
View File
@@ -1,68 +0,0 @@
--TEST--
Bug #76047: Use-after-free when accessing already destructed backtrace arguments
--FILE--
<?php
class Vuln {
public $a;
public function __destruct() {
unset($this->a);
$backtrace = (new Exception)->getTrace();
var_dump($backtrace);
}
}
function test($arg) {
$arg = str_shuffle(str_repeat('A', 79));
$vuln = new Vuln();
$vuln->a = $arg;
}
function test2($arg) {
$$arg = 1; // Trigger symbol table
$arg = str_shuffle(str_repeat('A', 79));
$vuln = new Vuln();
$vuln->a = $arg;
}
test('x');
test2('x');
?>
--EXPECTF--
array(1) {
[0]=>
array(6) {
["file"]=>
string(%d) "%s"
["line"]=>
int(%d)
["function"]=>
string(10) "__destruct"
["class"]=>
string(4) "Vuln"
["type"]=>
string(2) "->"
["args"]=>
array(0) {
}
}
}
array(1) {
[0]=>
array(6) {
["file"]=>
string(%d) "%s"
["line"]=>
int(%d)
["function"]=>
string(10) "__destruct"
["class"]=>
string(4) "Vuln"
["type"]=>
string(2) "->"
["args"]=>
array(0) {
}
}
}
-42
View File
@@ -1,42 +0,0 @@
--TEST--
Bug #77291 (magic methods inherited from a trait may be ignored)
--FILE--
<?php
trait AccessibleProperties
{
public function __isset($property)
{
return property_exists($this, $property);
}
public function __get($property)
{
if (property_exists($this, $property)) {
return $this->$property;
}
}
}
class Foo4567 {
use AccessibleProperties;
protected $a = 'Some value';
}
class Foo45 {
use AccessibleProperties;
protected $a = 'Some value';
}
$foo = new Foo4567;
var_dump(isset($foo->a));
$foo = new Foo45;
var_dump($foo->a);
?>
===DONE===
--EXPECT--
bool(true)
string(10) "Some value"
===DONE===
-33
View File
@@ -1,33 +0,0 @@
--TEST--
Bug #77339 (__callStatic may get incorrect arguments)
--FILE--
<?php
class Foo
{
static function __callStatic($name, $arguments) {
if ($name === 'get') {
if (!isset($arguments[0])) {
var_dump(['getSomeWhat']);
var_dump($arguments);
exit;
}
}
echo "OK\n";
}
protected function get ($key) {
echo "BUG!!!\n";
}
}
class Bar
{
static function __callStatic($name, $arguments) {
echo Foo::get('getSomeWhat');
}
}
Bar::someUndefinedStaticFunction();
?>
--EXPECT--
OK
-42
View File
@@ -1,42 +0,0 @@
--TEST--
Bug #77345 (Segmentation faults stack overflow in cyclic garbage collector) (Bug #77427)
--INI--
zend.enable_gc = 1
--FILE--
<?php
class Node
{
/** @var Node */
public $previous;
/** @var Node */
public $next;
}
var_dump(gc_enabled());
var_dump('start');
$firstNode = new Node();
$firstNode->previous = $firstNode;
$firstNode->next = $firstNode;
$circularDoublyLinkedList = $firstNode;
for ($i = 0; $i < 200000; $i++) {
$currentNode = $circularDoublyLinkedList;
$nextNode = $circularDoublyLinkedList->next;
$newNode = new Node();
$newNode->previous = $currentNode;
$currentNode->next = $newNode;
$newNode->next = $nextNode;
$nextNode->previous = $newNode;
$circularDoublyLinkedList = $nextNode;
}
var_dump('end');
--EXPECT--
bool(true)
string(5) "start"
string(3) "end"
-48
View File
@@ -1,48 +0,0 @@
--TEST--
Bug #77345 (Segmentation faults stack overflow in cyclic garbage collector) (Bug #77427)
--INI--
zend.enable_gc = 1
--FILE--
<?php
class Node
{
/** @var Node */
public $previous;
/** @var Node */
public $next;
}
var_dump(gc_enabled());
var_dump('start');
function xxx() {
$firstNode = new Node();
$firstNode->previous = $firstNode;
$firstNode->next = $firstNode;
$circularDoublyLinkedList = $firstNode;
for ($i = 0; $i < 300000; $i++) {
$currentNode = $circularDoublyLinkedList;
$nextNode = $circularDoublyLinkedList->next;
$newNode = new Node();
$newNode->previous = $currentNode;
$currentNode->next = $newNode;
$newNode->next = $nextNode;
$nextNode->previous = $newNode;
$circularDoublyLinkedList = $nextNode;
}
}
xxx();
gc_collect_cycles();
var_dump('end');
--EXPECT--
bool(true)
string(5) "start"
string(3) "end"
-12
View File
@@ -1,12 +0,0 @@
--TEST--
Bug #77376 ("undefined function" message no longer includes namespace)
--FILE--
<?php
namespace Hello;
World();
?>
--EXPECTF--
Fatal error: Uncaught Error: Call to undefined function Hello\World() %sbug77376.php:%d
Stack trace:
#0 {main}
thrown in %sbug77376.php on line %d
-16
View File
@@ -1,16 +0,0 @@
--TEST--
Bug #77494 (Disabling class causes segfault on member access)
--SKIPIF--
<?php if (!extension_loaded("curl")) exit("skip curl extension not loaded"); ?>
--INI--
disable_classes=CURLFile
--FILE--
<?php
$a = new CURLFile();
var_dump($a->name);
?>
--EXPECTF--
Warning: CURLFile() has been disabled for security reasons in %sbug77494.php on line 2
Notice: Undefined property: CURLFile::$name in %sbug77494.php on line 3
NULL
-10
View File
@@ -1,10 +0,0 @@
--TEST--
Bug #77530: PHP crashes when parsing '(2)::class'
--FILE--
<?php
echo (2)::class;
?>
--EXPECTF--
Fatal error: Illegal class name in %s on line %d
-40
View File
@@ -1,40 +0,0 @@
--TEST--
BUG #77589 (Core dump using parse_ini_string with numeric sections)
--FILE--
<?php
var_dump(
parse_ini_string(<<<INI
[0]
a = 1
b = on
c = true
["true"]
a = 100
b = null
c = yes
INI
, TRUE, INI_SCANNER_TYPED));
?>
--EXPECT--
array(2) {
[0]=>
array(3) {
["a"]=>
int(1)
["b"]=>
bool(true)
["c"]=>
bool(true)
}
["true"]=>
array(3) {
["a"]=>
int(100)
["b"]=>
NULL
["c"]=>
bool(true)
}
}
-6
View File
@@ -1,6 +0,0 @@
<?php
return [
'I' => function() {
return new class implements I {};
},
];
-16
View File
@@ -1,16 +0,0 @@
--TEST--
Bug #77652: Anonymous classes can lose their interface information
--FILE--
<?php
interface I {}
require __DIR__ . '/bug77652.inc';
$data = require __DIR__ . '/bug77652.inc';
print_r(class_implements($data['I']()));
?>
--EXPECT--
Array
(
[I] => I
)
-10
View File
@@ -1,10 +0,0 @@
--TEST--
Bug #77660 (Segmentation fault on break 2147483648)
--SKIPIF--
<?php if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platform only"); ?>
--FILE--
<?php
for(;;) break 2147483648;
?>
--EXPECTF--
Fatal error: Cannot 'break' 2147483648 levels in %sbug77660.php on line %d
-8
View File
@@ -1,8 +0,0 @@
--TEST--
Bug #77738 (Nullptr deref in zend_compile_expr)
--FILE--
<?php
__COMPILER_HALT_OFFSET__;
; // <- important
--EXPECTF--
Warning: Use of undefined constant __COMPILER_HALT_OFFSET__ - assumed '__COMPILER_HALT_OFFSET__' %sbug77738.php on line %d
-20
View File
@@ -1,20 +0,0 @@
--TEST--
Bug #77922: Double release of doc comment on inherited shadow property
--FILE--
<?php
class A {
/** Foo */
private $prop;
}
class B extends A {
}
class C extends B {
}
?>
===DONE===
--EXPECT--
===DONE===
-7
View File
@@ -1,7 +0,0 @@
--TEST--
Bug #77993 (Wrong parse error for invalid hex literal on Windows)
--FILE--
<?php
0xg10;
--EXPECTF--
Parse error: syntax error, unexpected 'xg10' (T_STRING) in %s on line %d
-32
View File
@@ -1,32 +0,0 @@
--TEST--
Bug #78010: Segmentation fault during GC
--INI--
memory_limit=2G
--FILE--
<?php
class foo
{
public function __construct()
{
$this->x = $this;
for ($i = 0; $i < 898; $i++) { //Will not trigger with <898
$obj = [new stdClass, new stdClass]; //This must have at least 2 elements
$this->y[] = $obj;
}
}
}
for ($i = 0; $i < 2; ++$i) { //This must run >=2 (increasing the number of elements in the array *2 will not do)
$x = []; //This must be reset
foreach (array_fill(0, 389, 'x') as &$params) { //Will not trigger <389
$x[] = new foo;
}
}
echo "Completed\n";
?>
--EXPECT--
Completed
-27
View File
@@ -1,27 +0,0 @@
--TEST--
Bug #78271: Invalid result of if-else
--FILE--
<?php
function test($a, $b){
if ($a==10) {
$w="x";
} else {
$w="y";
}
if ($b) {
$d1="none";
$d2="block";
} else {
$d1="block";
$d2="none";
}
echo $d2.$b."\n";
}
test(1, 1);
?>
--EXPECT--
block1
Binary file not shown.
-32
View File
@@ -1,32 +0,0 @@
--TEST--
Bug #78379 (Cast to object confuses GC, causes crash)
--INI--
opcache.enable=0
--FILE--
<?php
class C {
public function __construct() {
$this->p = (object)["x" => [1]];
}
}
class E {
}
$e = new E;
$e->f = new E;
$e->f->e = $e;
$e->a = new C;
$e = null;
gc_collect_cycles();
var_dump(new C);
?>
--EXPECTF--
object(C)#%d (1) {
["p"]=>
object(stdClass)#%d (1) {
["x"]=>
array(1) {
[0]=>
int(1)
}
}
}
-19
View File
@@ -1,19 +0,0 @@
--TEST--
Bug #78379.2 (Cast to object confuses GC, causes crash)
--FILE--
<?php
class E {}
function f() {
$e1 = new E;
$e2 = new E;
$a = ['e2' => $e2];
$e1->a = (object)$a;
$e2->e1 = $e1;
$e2->a = (object)$a;
}
f();
gc_collect_cycles();
echo "End\n";
?>
--EXPECT--
End
-14
View File
@@ -1,14 +0,0 @@
--TEST--
Bug #78658: Memory corruption using Closure::bindTo()
--FILE--
<?php
$c = function(){};
$scope = "AAAA";
$scope = "{$scope}BBBB";
$c->bindTo(new stdClass, $scope);
?>
--EXPECTF--
Warning: Class 'AAAABBBB' not found in %s on line %d
-13
View File
@@ -1,13 +0,0 @@
--TEST--
Bug #78689: Closure::fromCallable() doesn't handle [Closure, '__invoke']
--FILE--
<?php
$a = [function () { echo "123\n"; }, '__invoke'];
$a();
$b = Closure::fromCallable($a);
$b();
?>
--EXPECT--
123
123
-24
View File
@@ -1,24 +0,0 @@
--TEST--
Bug #78752: Segfault if GC triggered while generator stack frame is being destroyed
--FILE--
<?php
function gen(&$gen) {
$a = new stdClass;
$a->a = $a;
$b = new stdClass;
$b->b = $b;
yield 1;
}
$gen = gen($gen);
var_dump($gen->current());
for ($i = 0; $i < 9999; $i++) {
$a = new stdClass;
$a->a = $a;
}
$gen->next();
?>
--EXPECT--
int(1)
-22
View File
@@ -1,22 +0,0 @@
--TEST--
Bug #78787: Segfault with trait overriding inherited private shadow property
--FILE--
<?php
trait T {
private $prop;
}
class C1 {
/** Doc comment */
private $prop;
}
class C2 extends C1 {
}
class C3 extends C2 {
use T;
}
?>
===DONE===
--EXPECT--
===DONE===
-33
View File
@@ -1,33 +0,0 @@
--TEST--
Bug #78868: Calling __autoload() with incorrect EG(fake_scope) value
--FILE--
<?php
class C {
private $private = 1;
function foo() {
$this->private++; //fails with EG(fake_scope) != NULL && EG(fake_scope) != "C"
}
}
class A {
static $foo = B::foo; //not resolved on include()
}
function main_autoload($class_name) {
$c = new C;
$c->foo();
//doesn't affect the error
eval("class B {const foo = 1;}");
}
spl_autoload_register('main_autoload', false);
$classA = new ReflectionClass("A");
$props = $classA->getProperties();
$props[0]->setValue(2); //causes constant resolving, which runs autoload, all with EG(fake_scope) == "A"
echo "OK\n";
?>
--EXPECT--
OK
-36
View File
@@ -1,36 +0,0 @@
--TEST--
Bug #78921: When Reflection triggers class load, property visibility is incorrect
--FILE--
<?php
spl_autoload_register(function($className) {
if ($className == 'PrivateStatic') {
class PrivateStatic
{
const SOME_CONST = 13;
private static $privateStaticVarArray = ['a', 'b', 'c'];
private static $otherStatic;
public static function init()
{
self::$otherStatic = self::$privateStaticVarArray;
}
}
PrivateStatic::init();
}
});
class OtherClass
{
const MY_CONST = PrivateStatic::SOME_CONST;
public static $prop = 'my property';
}
$reflectionClass = new ReflectionClass('OtherClass');
$reflectionProperty = $reflectionClass->getProperty('prop');
$reflectionProperty->setAccessible(true);
$value = $reflectionProperty->getValue();
echo "Value is $value\n";
?>
--EXPECT--
Value is my property
-17
View File
@@ -1,17 +0,0 @@
--TEST--
Bug #78999 (Cycle leak when using function result as temporary)
--FILE--
<?php
function get() {
$t = new stdClass;
$t->prop = $t;
return $t;
}
var_dump(get());
var_dump(gc_collect_cycles());
--EXPECT--
object(stdClass)#1 (1) {
["prop"]=>
*RECURSION*
}
int(1)
-22
View File
@@ -1,22 +0,0 @@
--TEST--
Bug #79364 (When copy empty array, next key is unspecified)
--FILE--
<?php
$a = [1, 2];
unset($a[1], $a[0]);
$b = $a;
$a[] = 3;
$b[] = 4;
var_dump($a, $b);
?>
--EXPECT--
array(1) {
[2]=>
int(3)
}
array(1) {
[2]=>
int(4)
}
-20
View File
@@ -1,20 +0,0 @@
--TEST--
Bug #79477: casting object into array creates references
--FILE--
<?php
class Test {
public $prop = 'default value';
}
$obj = new Test;
$obj->{1} = null;
$arr = (array) $obj;
$arr['prop'] = 'new value';
echo $obj->prop, "\n";
?>
--EXPECT--
default value
-16
View File
@@ -1,16 +0,0 @@
--TEST--
Bug #79668 (get_defined_functions(true) may miss functions)
--INI--
disable_functions=sha1_file,password_hash
--FILE--
<?php
$df = get_defined_functions(true);
foreach (['sha1', 'sha1_file', 'hash', 'password_hash'] as $funcname) {
var_dump(in_array($funcname, $df['internal'], true));
}
?>
--EXPECT--
bool(true)
bool(false)
bool(true)
bool(false)
-26
View File
@@ -1,26 +0,0 @@
--TEST--
Bug #79778: Assertion failure if dumping closure with unresolved static variable
--FILE--
<?php
$closure1 = function() {
static $var = CONST_REF;
};
var_dump($closure1);
print_r($closure1);
?>
--EXPECT--
object(Closure)#1 (1) {
["static"]=>
array(1) {
["var"]=>
string(14) "<constant ast>"
}
}
Closure Object
(
[static] => Array
(
[var] => <constant ast>
)
)
-16
View File
@@ -1,16 +0,0 @@
--TEST--
Bug #79792: HT iterators not removed if empty array is destroyed
--FILE--
<?php
$a = [42];
foreach ($a as &$c) {
// Make the array empty.
unset($a[0]);
// Destroy the array.
$a = null;
}
?>
===DONE===
--EXPECTF--
Warning: Invalid argument supplied for foreach() in %s on line %d
===DONE===
@@ -9,7 +9,6 @@ namespace {
var_dump(FOO); // Ok
var_dump(foo); // Deprecated
var_dump(\foo); // Deprecated
var_dump(NS\FOO); // Ok
var_dump(ns\FOO); // Ok
@@ -73,13 +72,10 @@ int(42)
Deprecated: Case-insensitive constants are deprecated. The correct casing for this constant is "FOO" in %s on line 8
int(42)
Deprecated: Case-insensitive constants are deprecated. The correct casing for this constant is "FOO" in %s on line 9
int(42)
int(24)
int(24)
Deprecated: Case-insensitive constants are deprecated. The correct casing for this constant is "NS\FOO" in %s on line 13
Deprecated: Case-insensitive constants are deprecated. The correct casing for this constant is "NS\FOO" in %s on line 12
int(24)
bool(true)
bool(true)
@@ -88,24 +84,24 @@ bool(true)
bool(true)
int(42)
Deprecated: Case-insensitive constants are deprecated. The correct casing for this constant is "FOO" in %s on line 22
Deprecated: Case-insensitive constants are deprecated. The correct casing for this constant is "FOO" in %s on line 21
int(42)
int(24)
int(24)
Deprecated: Case-insensitive constants are deprecated. The correct casing for this constant is "NS\FOO" in %s on line 25
Deprecated: Case-insensitive constants are deprecated. The correct casing for this constant is "NS\FOO" in %s on line 24
int(24)
int(24)
Deprecated: Case-insensitive constants are deprecated. The correct casing for this constant is "NS\FOO" in %s on line 30
Deprecated: Case-insensitive constants are deprecated. The correct casing for this constant is "NS\FOO" in %s on line 29
int(24)
int(24)
Deprecated: Case-insensitive constants are deprecated. The correct casing for this constant is "NS\FOO" in %s on line 35
Deprecated: Case-insensitive constants are deprecated. The correct casing for this constant is "NS\FOO" in %s on line 34
int(24)
int(42)
Deprecated: Case-insensitive constants are deprecated. The correct casing for this constant is "FOO" in %s on line 40
Deprecated: Case-insensitive constants are deprecated. The correct casing for this constant is "FOO" in %s on line 39
int(42)
bool(true)
bool(true)
@@ -114,18 +110,18 @@ bool(true)
bool(true)
int(42)
Deprecated: Case-insensitive constants are deprecated. The correct casing for this constant is "FOO" in %s on line 49
Deprecated: Case-insensitive constants are deprecated. The correct casing for this constant is "FOO" in %s on line 48
int(42)
int(24)
int(24)
Deprecated: Case-insensitive constants are deprecated. The correct casing for this constant is "NS\FOO" in %s on line 52
Deprecated: Case-insensitive constants are deprecated. The correct casing for this constant is "NS\FOO" in %s on line 51
int(24)
int(42)
Deprecated: Case-insensitive constants are deprecated. The correct casing for this constant is "FOO" in %s on line 56
Deprecated: Case-insensitive constants are deprecated. The correct casing for this constant is "FOO" in %s on line 55
int(42)
int(43)
Deprecated: Case-insensitive constants are deprecated. The correct casing for this constant is "FOO" in %s on line 60
Deprecated: Case-insensitive constants are deprecated. The correct casing for this constant is "FOO" in %s on line 59
int(43)
-11
View File
@@ -1,11 +0,0 @@
--TEST--
Immediately invoked closure with extra args
--FILE--
<?php
(function() {})(new stdClass);
?>
===DONE===
--EXPECT--
===DONE===
-9
View File
@@ -1,9 +0,0 @@
--TEST--
Incorrect constant evaluation of and/or (OSS-Fuzz #19255)
--FILE--
<?php
const C = 0 && __namespace__;
var_dump(C);
?>
--EXPECT--
bool(false)
-28
View File
@@ -1,28 +0,0 @@
--TEST--
Freeing of function "name" when dynamic call fails
--FILE--
<?php
try {
$bar = "bar";
("foo" . $bar)();
} catch (Error $e) {
echo $e->getMessage(), "\n";
}
try {
$bar = ["bar"];
(["foo"] + $bar)();
} catch (Error $e) {
echo $e->getMessage(), "\n";
}
try {
(new stdClass)();
} catch (Error $e) {
echo $e->getMessage(), "\n";
}
?>
--EXPECT--
Call to undefined function foobar()
Function name must be a string
Function name must be a string
@@ -1,30 +0,0 @@
--TEST--
Calling exception getters when properties hold references
--FILE--
<?php
class MyException extends Exception {
public function __construct(&$refMsg, &$refCode, &$refFile, &$refLine) {
$this->message =& $refMsg;
$this->code =& $refCode;
$this->file =& $refFile;
$this->line =& $refLine;
}
}
$refMsg = "foo";
$refCode = 0;
$refFile = "foobar";
$refLine = 42;
$ex = new MyException($refMsg, $refCode, $refFile, $refLine);
var_dump($ex->getMessage());
var_dump($ex->getCode());
var_dump($ex->getFile());
var_dump($ex->getLine());
?>
--EXPECT--
string(3) "foo"
int(0)
string(6) "foobar"
int(42)
@@ -1,20 +0,0 @@
--TEST--
Leak when setting recursive previous exception in finally handling
--FILE--
<?php
try {
try {
throw new Exception("Test");
} catch (Exception $e) {
throw $e;
} finally {
throw $e;
}
} catch (Exception $e2) {
echo $e2->getMessage(), "\n";
}
?>
--EXPECT--
Test
@@ -1,18 +0,0 @@
--TEST--
Perform a packed to hash insert when the iterator is at the end of the array
--FILE--
<?php
$a = [];
$a[1] = 1;
foreach ($a as $k => &$v) {
var_dump($v);
if ($k == 1) $a[4] = 4;
if ($k == 4) $a[2] = 2;
}
?>
--EXPECT--
int(1)
int(4)
int(2)
-35
View File
@@ -1,35 +0,0 @@
--TEST--
GC 041: Handling of references in nested data of objects with destructor
--INI--
zend.enable_gc = 1
--FILE--
<?php
class ryat {
var $ryat;
var $chtg;
var $nested;
function __destruct() {
$GLOBALS['x'] = $this;
}
}
$o = new ryat;
$o->nested = [];
$o->nested[] =& $o->nested;
$o->ryat = $o;
$x =& $o->chtg;
unset($o);
gc_collect_cycles();
var_dump($x);
?>
--EXPECT--
object(ryat)#1 (3) {
["ryat"]=>
*RECURSION*
["chtg"]=>
*RECURSION*
["nested"]=>
&array(1) {
[0]=>
*RECURSION*
}
}
-28
View File
@@ -1,28 +0,0 @@
--TEST--
Object properties HT may need to be removed from nested data
--FILE--
<?php
class Test {
public function __destruct() {
$GLOBALS['x'] = $this;
}
}
$t = new Test;
$t->x = new stdClass;
$t->x->t = $t;
$a = (array) $t->x;
unset($t, $a);
gc_collect_cycles();
var_dump($x);
?>
--EXPECT--
object(Test)#1 (1) {
["x"]=>
object(stdClass)#2 (1) {
["t"]=>
*RECURSION*
}
}
@@ -1,30 +0,0 @@
--TEST--
Generator exceptions during shutdown should not be swallowed
--FILE--
<?php
function gen() {
try {
echo "before yield\n";
yield;
echo "after yield\n";
} finally {
echo "before yield in finally\n";
yield;
echo "after yield in finally\n";
}
echo "after finally\n";
}
$gen = gen();
$gen->rewind();
?>
--EXPECTF--
before yield
before yield in finally
Fatal error: Uncaught Error: Cannot yield from finally in a force-closed generator in %s:%d
Stack trace:
#0 {main}
thrown in %s on line %d
-24
View File
@@ -1,24 +0,0 @@
--TEST--
Bug #78441 (Parse error due to heredoc identifier followed by digit)
--FILE--
<?php
echo <<<FOO
FOO4
FOO, PHP_EOL;
echo <<<FOO
bar
FOO4
FOO, PHP_EOL;
echo <<<'FOO'
bar
FOO4
FOO, PHP_EOL;
?>
--EXPECT--
FOO4
bar
FOO4
bar
FOO4
-8
View File
@@ -1,8 +0,0 @@
--TEST--
Using __COMPILER_HALF_OFFSET__ with trailing {} (OSS-Fuzz #17895)
--FILE--
<?php
__COMPILER_HALT_OFFSET__;
{}
--EXPECTF--
Warning: Use of undefined constant __COMPILER_HALT_OFFSET__ - assumed '__COMPILER_HALT_OFFSET__' (this will throw an Error in a future version of PHP) in %s on line %d
-18
View File
@@ -1,18 +0,0 @@
--TEST--
Inherit internal static property into userland class
--SKIPIF--
<?php if (!extension_loaded('zend-test')) die('skip requires zend-test'); ?>
--FILE--
<?php
class Test extends _ZendTestClass {
}
var_dump(Test::$_StaticProp);
_ZendTestClass::$_StaticProp = 42;
var_dump(Test::$_StaticProp);
?>
--EXPECT--
NULL
int(42)
-14
View File
@@ -1,14 +0,0 @@
--TEST--
Bug object gc not working in shutdown
--FILE--
<?php
ini_set('memory_limit', '2M');
register_shutdown_function(function () {
for ($n = 1000 * 1000; $n--;) {
new stdClass;
}
echo "OK\n";
});
?>
--EXPECT--
OK
-17
View File
@@ -1,17 +0,0 @@
--TEST--
Memory leak on ** with result==op1 array
--FILE--
<?php
$x = [0];
$x **= 1;
var_dump($x);
$x = [0];
$x **= $x;
var_dump($x);
?>
--EXPECT--
int(0)
int(0)
@@ -1,23 +0,0 @@
--TEST--
Use of self::class inside a constant in an unknown scope
--FILE--
<?php
class Test {
public function foobar() {
eval("
const FOO = self::class;
var_dump(FOO);
");
}
}
(new Test)->foobar();
// This should error, but doesn't
const BAR = self::class;
var_dump(BAR);
?>
--EXPECT--
string(4) "Test"
string(0) ""
@@ -1,15 +0,0 @@
--TEST--
Calling a static method on a non-existing class
--FILE--
<?php
$str = "foo";
try {
Test::{$str . "bar"}();
} catch (Error $e) {
echo $e->getMessage(), "\n";
}
?>
--EXPECT--
Class 'Test' not found
@@ -1,17 +0,0 @@
--TEST--
The parent class is not necessarily the class of the prototype
--FILE--
<?php
class A {
function test(): B {}
}
class B extends A {}
class C extends B {
function test(): parent {}
}
?>
===DONE===
--EXPECT--
===DONE===
@@ -1,20 +0,0 @@
--TEST--
No warnings should be thrown during heredoc scan-ahead
--FILE--
<?php
<<<TEST
${x}
\400
${/*}
TEST;
?>
--EXPECTF--
Warning: Unexpected character in input: '' (ASCII=1) state=0 in %s on line %d
Warning: Octal escape sequence overflow \400 is greater than \377 in %s on line %d
Warning: Unterminated comment starting line %d in %s on line %d
Parse error: syntax error, unexpected end of file in %s on line %d
+16 -16
View File
@@ -373,17 +373,17 @@ ZEND_API void zend_print_flat_zval_r(zval *expr) /* {{{ */
switch (Z_TYPE_P(expr)) {
case IS_ARRAY:
ZEND_PUTS("Array (");
if (!(GC_FLAGS(Z_ARRVAL_P(expr)) & GC_IMMUTABLE)) {
if (GC_IS_RECURSIVE(Z_ARRVAL_P(expr))) {
if (Z_REFCOUNTED_P(expr)) {
if (Z_IS_RECURSIVE_P(expr)) {
ZEND_PUTS(" *RECURSION*");
return;
}
GC_PROTECT_RECURSION(Z_ARRVAL_P(expr));
Z_PROTECT_RECURSION_P(expr);
}
print_flat_hash(Z_ARRVAL_P(expr));
ZEND_PUTS(")");
if (!(GC_FLAGS(Z_ARRVAL_P(expr)) & GC_IMMUTABLE)) {
GC_UNPROTECT_RECURSION(Z_ARRVAL_P(expr));
if (Z_REFCOUNTED_P(expr)) {
Z_UNPROTECT_RECURSION_P(expr);
}
break;
case IS_OBJECT:
@@ -393,7 +393,7 @@ ZEND_API void zend_print_flat_zval_r(zval *expr) /* {{{ */
zend_printf("%s Object (", ZSTR_VAL(class_name));
zend_string_release_ex(class_name, 0);
if (GC_IS_RECURSIVE(Z_OBJ_P(expr))) {
if (Z_IS_RECURSIVE_P(expr)) {
ZEND_PUTS(" *RECURSION*");
return;
}
@@ -402,9 +402,9 @@ ZEND_API void zend_print_flat_zval_r(zval *expr) /* {{{ */
properties = Z_OBJPROP_P(expr);
}
if (properties) {
GC_PROTECT_RECURSION(Z_OBJ_P(expr));
Z_PROTECT_RECURSION_P(expr);
print_flat_hash(properties);
GC_UNPROTECT_RECURSION(Z_OBJ_P(expr));
Z_UNPROTECT_RECURSION_P(expr);
}
ZEND_PUTS(")");
break;
@@ -424,16 +424,16 @@ static void zend_print_zval_r_to_buf(smart_str *buf, zval *expr, int indent) /*
switch (Z_TYPE_P(expr)) {
case IS_ARRAY:
smart_str_appends(buf, "Array\n");
if (!(GC_FLAGS(Z_ARRVAL_P(expr)) & GC_IMMUTABLE)) {
if (GC_IS_RECURSIVE(Z_ARRVAL_P(expr))) {
if (Z_REFCOUNTED_P(expr)) {
if (Z_IS_RECURSIVE_P(expr)) {
smart_str_appends(buf, " *RECURSION*");
return;
}
GC_PROTECT_RECURSION(Z_ARRVAL_P(expr));
Z_PROTECT_RECURSION_P(expr);
}
print_hash(buf, Z_ARRVAL_P(expr), indent, 0);
if (!(GC_FLAGS(Z_ARRVAL_P(expr)) & GC_IMMUTABLE)) {
GC_UNPROTECT_RECURSION(Z_ARRVAL_P(expr));
if (Z_REFCOUNTED_P(expr)) {
Z_UNPROTECT_RECURSION_P(expr);
}
break;
case IS_OBJECT:
@@ -446,7 +446,7 @@ static void zend_print_zval_r_to_buf(smart_str *buf, zval *expr, int indent) /*
zend_string_release_ex(class_name, 0);
smart_str_appends(buf, " Object\n");
if (GC_IS_RECURSIVE(Z_OBJ_P(expr))) {
if (Z_IS_RECURSIVE_P(expr)) {
smart_str_appends(buf, " *RECURSION*");
return;
}
@@ -454,9 +454,9 @@ static void zend_print_zval_r_to_buf(smart_str *buf, zval *expr, int indent) /*
break;
}
GC_PROTECT_RECURSION(Z_OBJ_P(expr));
Z_PROTECT_RECURSION_P(expr);
print_hash(buf, properties, indent, 1);
GC_UNPROTECT_RECURSION(Z_OBJ_P(expr));
Z_UNPROTECT_RECURSION_P(expr);
if (is_temp) {
zend_hash_destroy(properties);
+1 -1
View File
@@ -20,7 +20,7 @@
#ifndef ZEND_H
#define ZEND_H
#define ZEND_VERSION "3.3.21"
#define ZEND_VERSION "3.3.0-dev"
#define ZEND_ENGINE_3
+13 -40
View File
@@ -2051,13 +2051,13 @@ ZEND_API zend_module_entry* zend_register_module_ex(zend_module_entry *module) /
}
name_len = strlen(module->name);
lcname = zend_string_alloc(name_len, module->type == MODULE_PERSISTENT);
lcname = zend_string_alloc(name_len, 1);
zend_str_tolower_copy(ZSTR_VAL(lcname), module->name, name_len);
lcname = zend_new_interned_string(lcname);
if ((module_ptr = zend_hash_add_mem(&module_registry, lcname, module, sizeof(zend_module_entry))) == NULL) {
zend_error(E_CORE_WARNING, "Module '%s' already loaded", module->name);
zend_string_release(lcname);
zend_string_release_ex(lcname, 1);
return NULL;
}
module = module_ptr;
@@ -2065,14 +2065,14 @@ ZEND_API zend_module_entry* zend_register_module_ex(zend_module_entry *module) /
if (module->functions && zend_register_functions(NULL, module->functions, NULL, module->type)==FAILURE) {
zend_hash_del(&module_registry, lcname);
zend_string_release(lcname);
zend_string_release_ex(lcname, 1);
EG(current_module) = NULL;
zend_error(E_CORE_WARNING,"%s: Unable to register functions, unable to load", module->name);
return NULL;
}
EG(current_module) = NULL;
zend_string_release(lcname);
zend_string_release_ex(lcname, 1);
return module;
}
/* }}} */
@@ -2279,14 +2279,14 @@ ZEND_API int zend_register_functions(zend_class_entry *scope, const zend_functio
return FAILURE;
}
}
lowercase_name = zend_string_tolower_ex(internal_function->function_name, type == MODULE_PERSISTENT);
lowercase_name = zend_string_tolower_ex(internal_function->function_name, 1);
lowercase_name = zend_new_interned_string(lowercase_name);
reg_function = malloc(sizeof(zend_internal_function));
memcpy(reg_function, &function, sizeof(zend_internal_function));
if (zend_hash_add_ptr(target_function_table, lowercase_name, reg_function) == NULL) {
unload=1;
free(reg_function);
zend_string_release(lowercase_name);
zend_string_release_ex(lowercase_name, 1);
break;
}
@@ -2378,7 +2378,7 @@ ZEND_API int zend_register_functions(zend_class_entry *scope, const zend_functio
}
ptr++;
count++;
zend_string_release(lowercase_name);
zend_string_release_ex(lowercase_name, 1);
}
if (unload) { /* before unloading, display all remaining bad function in the module */
if (scope) {
@@ -2724,10 +2724,10 @@ static zend_class_entry *do_register_internal_class(zend_class_entry *orig_class
class_entry->info.internal.module = EG(current_module);
if (class_entry->info.internal.builtin_functions) {
zend_register_functions(class_entry, class_entry->info.internal.builtin_functions, &class_entry->function_table, EG(current_module)->type);
zend_register_functions(class_entry, class_entry->info.internal.builtin_functions, &class_entry->function_table, MODULE_PERSISTENT);
}
lowercase_name = zend_string_tolower_ex(orig_class_entry->name, EG(current_module)->type == MODULE_PERSISTENT);
lowercase_name = zend_string_tolower_ex(orig_class_entry->name, 1);
lowercase_name = zend_new_interned_string(lowercase_name);
zend_hash_update_ptr(CG(class_table), lowercase_name, class_entry);
zend_string_release_ex(lowercase_name, 1);
@@ -2786,11 +2786,6 @@ ZEND_API int zend_register_class_alias_ex(const char *name, size_t name_len, zen
{
zend_string *lcname;
/* TODO: Move this out of here in 7.4. */
if (persistent && EG(current_module) && EG(current_module)->type == MODULE_TEMPORARY) {
persistent = 0;
}
if (name[0] == '\\') {
lcname = zend_string_alloc(name_len-1, persistent);
zend_str_tolower_copy(ZSTR_VAL(lcname), name+1, name_len-1);
@@ -2848,7 +2843,7 @@ ZEND_API int zend_disable_function(char *function_name, size_t function_name_len
{
zend_internal_function *func;
if ((func = zend_hash_str_find_ptr(CG(function_table), function_name, function_name_length))) {
func->fn_flags &= ~(ZEND_ACC_VARIADIC | ZEND_ACC_HAS_TYPE_HINTS | ZEND_ACC_HAS_RETURN_TYPE);
func->fn_flags &= ~(ZEND_ACC_VARIADIC | ZEND_ACC_HAS_TYPE_HINTS);
func->num_args = 0;
func->arg_info = NULL;
func->handler = ZEND_FN(display_disabled_function);
@@ -2866,17 +2861,6 @@ static zend_object *display_disabled_class(zend_class_entry *class_type) /* {{{
zend_object *intern;
intern = zend_objects_new(class_type);
/* Initialize default properties */
if (EXPECTED(class_type->default_properties_count != 0)) {
zval *p = intern->properties_table;
zval *end = p + class_type->default_properties_count;
do {
ZVAL_UNDEF(p);
p++;
} while (p != end);
}
zend_error(E_WARNING, "%s() has been disabled for security reasons", ZSTR_VAL(class_type->name));
return intern;
}
@@ -3701,11 +3685,6 @@ static inline zend_string *zval_make_interned_string(zval *zv) /* {{{ */
return Z_STR_P(zv);
}
static zend_always_inline zend_bool is_persistent_class(zend_class_entry *ce) {
return (ce->type & ZEND_INTERNAL_CLASS)
&& ce->info.internal.module->type == MODULE_PERSISTENT;
}
ZEND_API int zend_declare_property_ex(zend_class_entry *ce, zend_string *name, zval *property, int access_type, zend_string *doc_comment) /* {{{ */
{
zend_property_info *property_info, *property_info_ptr;
@@ -3771,10 +3750,10 @@ ZEND_API int zend_declare_property_ex(zend_class_entry *ce, zend_string *name, z
if (access_type & ZEND_ACC_PUBLIC) {
property_info->name = zend_string_copy(name);
} else if (access_type & ZEND_ACC_PRIVATE) {
property_info->name = zend_mangle_property_name(ZSTR_VAL(ce->name), ZSTR_LEN(ce->name), ZSTR_VAL(name), ZSTR_LEN(name), is_persistent_class(ce));
property_info->name = zend_mangle_property_name(ZSTR_VAL(ce->name), ZSTR_LEN(ce->name), ZSTR_VAL(name), ZSTR_LEN(name), ce->type & ZEND_INTERNAL_CLASS);
} else {
ZEND_ASSERT(access_type & ZEND_ACC_PROTECTED);
property_info->name = zend_mangle_property_name("*", 1, ZSTR_VAL(name), ZSTR_LEN(name), is_persistent_class(ce));
property_info->name = zend_mangle_property_name("*", 1, ZSTR_VAL(name), ZSTR_LEN(name), ce->type & ZEND_INTERNAL_CLASS);
}
property_info->name = zend_new_interned_string(property_info->name);
@@ -3789,7 +3768,7 @@ ZEND_API int zend_declare_property_ex(zend_class_entry *ce, zend_string *name, z
ZEND_API int zend_declare_property(zend_class_entry *ce, const char *name, size_t name_length, zval *property, int access_type) /* {{{ */
{
zend_string *key = zend_string_init(name, name_length, is_persistent_class(ce));
zend_string *key = zend_string_init(name, name_length, ce->type & ZEND_INTERNAL_CLASS);
int ret = zend_declare_property_ex(ce, key, property, access_type, NULL);
zend_string_release(key);
return ret;
@@ -4082,12 +4061,6 @@ ZEND_API int zend_update_static_property_ex(zend_class_entry *scope, zend_string
zval *property;
zend_class_entry *old_scope = EG(fake_scope);
if (UNEXPECTED(!(scope->ce_flags & ZEND_ACC_CONSTANTS_UPDATED))) {
if (UNEXPECTED(zend_update_class_constants(scope)) != SUCCESS) {
return FAILURE;
}
}
EG(fake_scope) = scope;
property = zend_std_get_static_property(scope, name, 0);
EG(fake_scope) = old_scope;
+15 -20
View File
@@ -191,7 +191,9 @@ typedef struct _zend_mm_free_slot zend_mm_free_slot;
typedef struct _zend_mm_chunk zend_mm_chunk;
typedef struct _zend_mm_huge_list zend_mm_huge_list;
#ifdef MAP_HUGETLB
int zend_mm_use_huge_pages = 0;
#endif
/*
* Memory is retrived from OS by chunks of fixed size 2MB.
@@ -712,9 +714,7 @@ static void *zend_mm_chunk_alloc_int(size_t size, size_t alignment)
return NULL;
} else if (ZEND_MM_ALIGNED_OFFSET(ptr, alignment) == 0) {
#ifdef MADV_HUGEPAGE
if (zend_mm_use_huge_pages) {
madvise(ptr, size, MADV_HUGEPAGE);
}
madvise(ptr, size, MADV_HUGEPAGE);
#endif
return ptr;
} else {
@@ -745,9 +745,7 @@ static void *zend_mm_chunk_alloc_int(size_t size, size_t alignment)
zend_mm_munmap((char*)ptr + size, alignment - REAL_PAGE_SIZE);
}
# ifdef MADV_HUGEPAGE
if (zend_mm_use_huge_pages) {
madvise(ptr, size, MADV_HUGEPAGE);
}
madvise(ptr, size, MADV_HUGEPAGE);
# endif
#endif
return ptr;
@@ -982,7 +980,7 @@ get_chunk:
heap->cached_chunks = chunk->next;
} else {
#if ZEND_MM_LIMIT
if (UNEXPECTED(ZEND_MM_CHUNK_SIZE > heap->limit - heap->real_size)) {
if (UNEXPECTED(heap->real_size + ZEND_MM_CHUNK_SIZE > heap->limit)) {
if (zend_mm_gc(heap)) {
goto get_chunk;
} else if (heap->overflow == 0) {
@@ -1510,8 +1508,8 @@ static zend_never_inline void *zend_mm_realloc_huge(zend_mm_heap *heap, void *pt
}
} else /* if (new_size > old_size) */ {
#if ZEND_MM_LIMIT
if (UNEXPECTED(new_size - old_size > heap->limit - heap->real_size)) {
if (zend_mm_gc(heap) && new_size - old_size <= heap->limit - heap->real_size) {
if (UNEXPECTED(heap->real_size + (new_size - old_size) > heap->limit)) {
if (zend_mm_gc(heap) && heap->real_size + (new_size - old_size) <= heap->limit) {
/* pass */
} else if (heap->overflow == 0) {
#if ZEND_DEBUG
@@ -1792,20 +1790,15 @@ static void *zend_mm_alloc_huge(zend_mm_heap *heap, size_t size ZEND_FILE_LINE_D
* We allocate them with 2MB size granularity, to avoid many
* reallocations when they are extended by small pieces
*/
size_t alignment = MAX(REAL_PAGE_SIZE, ZEND_MM_CHUNK_SIZE);
size_t new_size = ZEND_MM_ALIGNED_SIZE_EX(size, MAX(REAL_PAGE_SIZE, ZEND_MM_CHUNK_SIZE));
#else
size_t alignment = REAL_PAGE_SIZE;
size_t new_size = ZEND_MM_ALIGNED_SIZE_EX(size, REAL_PAGE_SIZE);
#endif
size_t new_size = ZEND_MM_ALIGNED_SIZE_EX(size, alignment);
void *ptr;
if (UNEXPECTED(new_size < size)) {
zend_error_noreturn(E_ERROR, "Possible integer overflow in memory allocation (%zu + %zu)", size, alignment);
}
#if ZEND_MM_LIMIT
if (UNEXPECTED(new_size > heap->limit - heap->real_size)) {
if (zend_mm_gc(heap) && new_size <= heap->limit - heap->real_size) {
if (UNEXPECTED(heap->real_size + new_size > heap->limit)) {
if (zend_mm_gc(heap) && heap->real_size + new_size <= heap->limit) {
/* pass */
} else if (heap->overflow == 0) {
#if ZEND_DEBUG
@@ -2103,7 +2096,6 @@ static zend_long zend_mm_find_leaks(zend_mm_heap *heap, zend_mm_chunk *p, uint32
}
}
p = p->next;
i = ZEND_MM_FIRST_PAGE;
} while (p != heap->main_chunk);
return count;
}
@@ -2676,7 +2668,9 @@ ZEND_API void shutdown_memory_manager(int silent, int full_shutdown)
static void alloc_globals_ctor(zend_alloc_globals *alloc_globals)
{
#if ZEND_MM_CUSTOM || MAP_HUGETLB
char *tmp;
#endif
#if ZEND_MM_CUSTOM
tmp = getenv("USE_ZEND_ALLOC");
@@ -2690,11 +2684,12 @@ static void alloc_globals_ctor(zend_alloc_globals *alloc_globals)
return;
}
#endif
#ifdef MAP_HUGETLB
tmp = getenv("USE_ZEND_ALLOC_HUGE_PAGES");
if (tmp && zend_atoi(tmp, 0)) {
zend_mm_use_huge_pages = 1;
}
#endif
ZEND_TSRMLS_CACHE_UPDATE();
alloc_globals->mm_heap = zend_mm_init();
}
-11
View File
@@ -110,17 +110,6 @@ static zend_always_inline void zend_arena_release(zend_arena **arena_ptr, void *
arena->ptr = (char*)checkpoint;
}
static zend_always_inline zend_bool zend_arena_contains(zend_arena *arena, void *ptr)
{
while (arena) {
if ((char*)ptr > (char*)arena && (char*)ptr <= arena->ptr) {
return 1;
}
arena = arena->prev;
}
return 0;
}
#endif /* _ZEND_ARENA_H_ */
/*
+3 -10
View File
@@ -995,11 +995,6 @@ static ZEND_COLD int zend_ast_valid_var_name(const char *s, size_t len)
return 1;
}
static ZEND_COLD int zend_ast_var_needs_braces(char ch)
{
return ch == '[' || zend_ast_valid_var_char(ch);
}
static ZEND_COLD void zend_ast_export_var(smart_str *str, zend_ast *ast, int priority, int indent)
{
if (ast->kind == ZEND_AST_ZVAL) {
@@ -1047,7 +1042,7 @@ static ZEND_COLD void zend_ast_export_encaps_list(smart_str *str, char quote, ze
ast->child[0]->kind == ZEND_AST_ZVAL &&
(i + 1 == list->children ||
list->child[i + 1]->kind != ZEND_AST_ZVAL ||
!zend_ast_var_needs_braces(
!zend_ast_valid_var_char(
*Z_STRVAL_P(
zend_ast_get_zval(list->child[i + 1]))))) {
zend_ast_export_ex(str, ast, 0, indent);
@@ -1158,7 +1153,7 @@ tail_call:
} else {
zend_ast_export_indent(str, indent);
smart_str_appends(str, "} else ");
if (ast->child[1] && ast->child[1]->kind == ZEND_AST_IF) {
if (ast->child[1]->kind == ZEND_AST_IF) {
list = (zend_ast_list*)ast->child[1];
goto tail_call;
} else {
@@ -1463,7 +1458,7 @@ simple_list:
}
break;
case ZEND_AST_TYPE:
switch (ast->attr & ~ZEND_TYPE_NULLABLE) {
switch (ast->attr) {
case IS_ARRAY: APPEND_STR("array");
case IS_CALLABLE: APPEND_STR("callable");
EMPTY_SWITCH_DEFAULT_CASE();
@@ -1664,8 +1659,6 @@ simple_list:
zend_ast_export_ex(str, ast->child[1], 80, indent);
smart_str_appends(str, " => ");
}
if (ast->attr)
smart_str_appendc(str, '&');
zend_ast_export_ex(str, ast->child[0], 80, indent);
break;
case ZEND_AST_NEW:
+15 -8
View File
@@ -1665,10 +1665,10 @@ ZEND_FUNCTION(set_error_handler)
if (Z_TYPE(EG(user_error_handler)) != IS_UNDEF) {
ZVAL_COPY(return_value, &EG(user_error_handler));
}
zend_stack_push(&EG(user_error_handlers_error_reporting), &EG(user_error_handler_error_reporting));
zend_stack_push(&EG(user_error_handlers), &EG(user_error_handler));
zend_stack_push(&EG(user_error_handlers_error_reporting), &EG(user_error_handler_error_reporting));
zend_stack_push(&EG(user_error_handlers), &EG(user_error_handler));
}
if (Z_TYPE_P(error_handler) == IS_NULL) { /* unset user-defined handler */
ZVAL_UNDEF(&EG(user_error_handler));
@@ -1732,9 +1732,9 @@ ZEND_FUNCTION(set_exception_handler)
if (Z_TYPE(EG(user_exception_handler)) != IS_UNDEF) {
ZVAL_COPY(return_value, &EG(user_exception_handler));
}
zend_stack_push(&EG(user_exception_handlers), &EG(user_exception_handler));
zend_stack_push(&EG(user_exception_handlers), &EG(user_exception_handler));
}
if (Z_TYPE_P(exception_handler) == IS_NULL) { /* unset user-defined handler */
ZVAL_UNDEF(&EG(user_exception_handler));
@@ -1847,9 +1847,16 @@ static int copy_function_name(zval *zv, int num_args, va_list args, zend_hash_ke
return 0;
}
if (func->type == ZEND_INTERNAL_FUNCTION
&& (!*exclude_disabled || func->internal_function.handler != ZEND_FN(display_disabled_function))) {
add_next_index_str(internal_ar, zend_string_copy(hash_key->key));
if (func->type == ZEND_INTERNAL_FUNCTION) {
char *disable_functions = INI_STR("disable_functions");
if ((*exclude_disabled == 1) && (disable_functions != NULL)) {
if (strstr(disable_functions, func->common.function_name->val) == NULL) {
add_next_index_str(internal_ar, zend_string_copy(hash_key->key));
}
} else {
add_next_index_str(internal_ar, zend_string_copy(hash_key->key));
}
} else if (func->type == ZEND_USER_FUNCTION) {
add_next_index_str(user_ar, zend_string_copy(hash_key->key));
}
+2 -17
View File
@@ -200,7 +200,7 @@ ZEND_METHOD(Closure, bind)
ce = closure->func.common.scope;
} else if ((ce = zend_lookup_class_ex(class_name, NULL, 1)) == NULL) {
zend_error(E_WARNING, "Class '%s' not found", ZSTR_VAL(class_name));
zend_tmp_string_release(tmp_class_name);
zend_string_release_ex(class_name, 0);
RETURN_NULL();
}
zend_tmp_string_release(tmp_class_name);
@@ -268,16 +268,8 @@ static int zend_create_closure_from_callable(zval *return_value, zval *callable,
mptr = fcc.function_handler;
if (mptr->common.fn_flags & ZEND_ACC_CALL_VIA_TRAMPOLINE) {
/* For Closure::fromCallable([$closure, "__invoke"]) return $closure. */
if (fcc.object && fcc.object->ce == zend_ce_closure
&& zend_string_equals_literal(mptr->common.function_name, "__invoke")) {
ZVAL_OBJ(return_value, fcc.object);
GC_ADDREF(fcc.object);
zend_free_trampoline(mptr);
return SUCCESS;
}
memset(&call, 0, sizeof(zend_internal_function));
call.type = ZEND_INTERNAL_FUNCTION;
call.fn_flags = mptr->common.fn_flags & ZEND_ACC_STATIC;
call.handler = zend_closure_call_magic;
@@ -506,16 +498,9 @@ static HashTable *zend_closure_get_debug_info(zval *object, int *is_temp) /* {{{
debug_info = zend_new_array(8);
if (closure->func.type == ZEND_USER_FUNCTION && closure->func.op_array.static_variables) {
zval *var;
HashTable *static_variables = closure->func.op_array.static_variables;
ZVAL_ARR(&val, zend_array_dup(static_variables));
zend_hash_update(debug_info, ZSTR_KNOWN(ZEND_STR_STATIC), &val);
ZEND_HASH_FOREACH_VAL(Z_ARRVAL(val), var) {
if (Z_TYPE_P(var) == IS_CONSTANT_AST) {
zval_ptr_dtor(var);
ZVAL_STRING(var, "<constant ast>");
}
} ZEND_HASH_FOREACH_END();
}
if (Z_TYPE(closure->this_ptr) != IS_UNDEF) {
+38 -102
View File
@@ -480,12 +480,10 @@ static inline zend_string *zval_make_interned_string(zval *zv) /* {{{ */
/* Common part of zend_add_literal and zend_append_individual_literal */
static inline void zend_insert_literal(zend_op_array *op_array, zval *zv, int literal_position) /* {{{ */
{
zval *lit = CT_CONSTANT_EX(op_array, literal_position);
if (Z_TYPE_P(zv) == IS_STRING) {
zval_make_interned_string(zv);
}
ZVAL_COPY_VALUE(lit, zv);
Z_EXTRA_P(lit) = 0;
ZVAL_COPY_VALUE(CT_CONSTANT_EX(op_array, literal_position), zv);
}
/* }}} */
@@ -1480,7 +1478,6 @@ static void zend_ensure_valid_class_fetch_type(uint32_t fetch_type) /* {{{ */
static zend_bool zend_try_compile_const_expr_resolve_class_name(zval *zv, zend_ast *class_ast, zend_ast *name_ast, zend_bool constant) /* {{{ */
{
uint32_t fetch_type;
zval *class_name;
if (name_ast->kind != ZEND_AST_ZVAL) {
return 0;
@@ -1495,18 +1492,12 @@ static zend_bool zend_try_compile_const_expr_resolve_class_name(zval *zv, zend_a
"Dynamic class names are not allowed in compile-time ::class fetch");
}
class_name = zend_ast_get_zval(class_ast);
if (Z_TYPE_P(class_name) != IS_STRING) {
zend_error_noreturn(E_COMPILE_ERROR, "Illegal class name");
}
fetch_type = zend_get_class_fetch_type(Z_STR_P(class_name));
fetch_type = zend_get_class_fetch_type(zend_ast_get_str(class_ast));
zend_ensure_valid_class_fetch_type(fetch_type);
switch (fetch_type) {
case ZEND_FETCH_CLASS_SELF:
if (CG(active_class_entry) && zend_is_scope_known()) {
if (constant || (CG(active_class_entry) && zend_is_scope_known())) {
ZVAL_STR_COPY(zv, CG(active_class_entry)->name);
} else {
ZVAL_NULL(zv);
@@ -1693,17 +1684,13 @@ ZEND_API void zend_activate_auto_globals(void) /* {{{ */
int ZEND_FASTCALL zendlex(zend_parser_stack_elem *elem) /* {{{ */
{
zval zv;
int ret;
if (CG(increment_lineno)) {
CG(zend_lineno)++;
CG(increment_lineno) = 0;
}
ret = lex_scan(&zv, elem);
ZEND_ASSERT(!EG(exception) || ret == T_ERROR);
return ret;
return lex_scan(&zv, elem);
}
/* }}} */
@@ -2457,6 +2444,7 @@ static inline void zend_handle_numeric_dim(zend_op *opline, znode *dim_node) /*
return;
}
}
Z_EXTRA_P(CT_CONSTANT(opline->op2)) = 0;
}
/* }}} */
@@ -3662,7 +3650,7 @@ int zend_compile_func_cuf(znode *result, zend_ast_list *args, zend_string *lcnam
}
/* }}} */
static void zend_compile_assert(znode *result, zend_ast_list *args, zend_string *name, zend_function *fbc) /* {{{ */
static int zend_compile_assert(znode *result, zend_ast_list *args, zend_string *name, zend_function *fbc) /* {{{ */
{
if (EG(assertions) >= 0) {
znode name_node;
@@ -3705,6 +3693,8 @@ static void zend_compile_assert(znode *result, zend_ast_list *args, zend_string
result->op_type = IS_CONST;
ZVAL_TRUE(&result->u.constant);
}
return SUCCESS;
}
/* }}} */
@@ -3911,6 +3901,10 @@ int zend_try_compile_special_func(znode *result, zend_string *lcname, zend_ast_l
return FAILURE;
}
if (zend_string_equals_literal(lcname, "assert")) {
return zend_compile_assert(result, args, lcname, fbc);
}
if (CG(compiler_options) & ZEND_COMPILE_NO_BUILTINS) {
return FAILURE;
}
@@ -4013,16 +4007,8 @@ void zend_compile_call(znode *result, zend_ast *ast, uint32_t type) /* {{{ */
zend_op *opline;
lcname = zend_string_tolower(Z_STR_P(name));
fbc = zend_hash_find_ptr(CG(function_table), lcname);
/* Special assert() handling should apply independently of compiler flags. */
if (fbc && zend_string_equals_literal(lcname, "assert")) {
zend_compile_assert(result, zend_ast_get_list(args_ast), lcname, fbc);
zend_string_release(lcname);
zval_ptr_dtor(&name_node.u.constant);
return;
}
if (!fbc
|| (fbc->type == ZEND_INTERNAL_FUNCTION && (CG(compiler_options) & ZEND_COMPILE_IGNORE_INTERNAL_FUNCTIONS))
|| (fbc->type == ZEND_USER_FUNCTION && (CG(compiler_options) & ZEND_COMPILE_IGNORE_USER_FUNCTIONS))
@@ -4166,14 +4152,6 @@ void zend_compile_static_call(znode *result, zend_ast *ast, uint32_t type) /* {{
if (ce) {
zend_string *lcname = Z_STR_P(CT_CONSTANT(opline->op2) + 1);
fbc = zend_hash_find_ptr(&ce->function_table, lcname);
if (fbc && !(fbc->common.fn_flags & ZEND_ACC_PUBLIC)) {
if (ce != CG(active_class_entry)
&&((fbc->common.fn_flags & ZEND_ACC_PRIVATE)
|| !zend_check_protected(zend_get_function_root_class(fbc), CG(active_class_entry)))) {
/* incompatibe function */
fbc = NULL;
}
}
}
}
@@ -4532,7 +4510,7 @@ void zend_compile_break_continue(zend_ast *ast) /* {{{ */
zend_ast *depth_ast = ast->child[0];
zend_op *opline;
zend_long depth;
int depth;
ZEND_ASSERT(ast->kind == ZEND_AST_BREAK || ast->kind == ZEND_AST_CONTINUE);
@@ -4559,7 +4537,7 @@ void zend_compile_break_continue(zend_ast *ast) /* {{{ */
ast->kind == ZEND_AST_BREAK ? "break" : "continue");
} else {
if (!zend_handle_loops_and_finally_ex(depth, NULL)) {
zend_error_noreturn(E_COMPILE_ERROR, "Cannot '%s' " ZEND_LONG_FMT " level%s",
zend_error_noreturn(E_COMPILE_ERROR, "Cannot '%s' %d level%s",
ast->kind == ZEND_AST_BREAK ? "break" : "continue",
depth, depth == 1 ? "" : "s");
}
@@ -4576,12 +4554,12 @@ void zend_compile_break_continue(zend_ast *ast) /* {{{ */
if (depth == 1) {
zend_error(E_WARNING,
"\"continue\" targeting switch is equivalent to \"break\". " \
"Did you mean to use \"continue " ZEND_LONG_FMT "\"?",
"Did you mean to use \"continue %d\"?",
depth + 1);
} else {
zend_error(E_WARNING,
"\"continue " ZEND_LONG_FMT "\" targeting switch is equivalent to \"break " ZEND_LONG_FMT "\". " \
"Did you mean to use \"continue " ZEND_LONG_FMT "\"?",
"\"continue %d\" targeting switch is equivalent to \"break %d\". " \
"Did you mean to use \"continue %d\"?",
depth, depth, depth + 1);
}
}
@@ -4867,10 +4845,6 @@ void zend_compile_foreach(zend_ast *ast) /* {{{ */
zend_compile_stmt(stmt_ast);
/* Place JMP and FE_FREE on the line where foreach starts. It would be
* better to use the end line, but this information is not available
* currently. */
CG(zend_lineno) = ast->lineno;
zend_emit_jump(opnum_fetch);
opline = &CG(active_op_array)->opcodes[opnum_reset];
@@ -4969,10 +4943,6 @@ static zend_uchar determine_switch_jumptable_type(zend_ast_list *cases) {
}
static zend_bool should_use_jumptable(zend_ast_list *cases, zend_uchar jumptable_type) {
if (CG(compiler_options) & ZEND_COMPILE_NO_JUMPTABLES) {
return 0;
}
/* Thresholds are chosen based on when the average switch time for equidistributed
* input becomes smaller when using the jumptable optimization. */
if (jumptable_type == IS_LONG) {
@@ -6444,32 +6414,10 @@ void zend_compile_class_decl(zend_ast *ast) /* {{{ */
if (!zend_hash_exists(CG(class_table), lcname)) {
zend_hash_add_ptr(CG(class_table), lcname, ce);
} else {
/* This anonymous class has been included, reuse the existing definition.
* NB: This behavior is buggy, and this should always result in a separate
* class declaration. However, until the problem of RTD key collisions is
* solved, this gives a behavior close to what is expected. */
/* this anonymous class has been included */
zval zv;
ZVAL_PTR(&zv, ce);
destroy_zend_class(&zv);
ce = zend_hash_find_ptr(CG(class_table), lcname);
/* Manually replicate emission of necessary inheritance opcodes here. We cannot
* reuse the general code, as we only want to emit the opcodes, without modifying
* the reused class definition. */
if (ce->ce_flags & ZEND_ACC_IMPLEMENT_TRAITS) {
zend_emit_op(NULL, ZEND_BIND_TRAITS, &declare_node, NULL);
}
if (implements_ast) {
zend_ast_list *iface_list = zend_ast_get_list(implements_ast);
uint32_t i;
for (i = 0; i < iface_list->children; i++) {
opline = zend_emit_op(NULL, ZEND_ADD_INTERFACE, &declare_node, NULL);
opline->op2_type = IS_CONST;
opline->op2.constant = zend_add_class_name_literal(CG(active_op_array),
zend_resolve_class_name_ast(iface_list->child[i]));
}
zend_emit_op(NULL, ZEND_VERIFY_ABSTRACT_CLASS, &declare_node, NULL);
}
return;
}
} else {
@@ -6698,7 +6646,6 @@ void zend_compile_use(zend_ast *ast) /* {{{ */
}
zend_string_addref(old_name);
old_name = zend_new_interned_string(old_name);
if (!zend_hash_add_ptr(current_import, lookup_name, old_name)) {
zend_error_noreturn(E_COMPILE_ERROR, "Cannot use%s %s as %s because the name "
"is already in use", zend_get_use_type_str(type), ZSTR_VAL(old_name), ZSTR_VAL(new_name));
@@ -7035,7 +6982,6 @@ static inline void zend_ct_eval_greater(zval *result, zend_ast_kind kind, zval *
static zend_bool zend_try_ct_eval_array(zval *result, zend_ast *ast) /* {{{ */
{
zend_ast_list *list = zend_ast_get_list(ast);
zend_ast *last_elem_ast = NULL;
uint32_t i;
zend_bool is_constant = 1;
@@ -7048,10 +6994,6 @@ static zend_bool zend_try_ct_eval_array(zval *result, zend_ast *ast) /* {{{ */
zend_ast *elem_ast = list->child[i];
if (elem_ast == NULL) {
/* Report error at line of last non-empty element */
if (last_elem_ast) {
CG(zend_lineno) = zend_ast_get_lineno(last_elem_ast);
}
zend_error(E_COMPILE_ERROR, "Cannot use empty array elements in arrays");
}
@@ -7063,8 +7005,6 @@ static zend_bool zend_try_ct_eval_array(zval *result, zend_ast *ast) /* {{{ */
) {
is_constant = 0;
}
last_elem_ast = elem_ast;
}
if (!is_constant) {
@@ -7766,14 +7706,11 @@ void zend_compile_const(znode *result, zend_ast *ast) /* {{{ */
if (zend_string_equals_literal(resolved_name, "__COMPILER_HALT_OFFSET__") || (name_ast->attr != ZEND_NAME_RELATIVE && zend_string_equals_literal(orig_name, "__COMPILER_HALT_OFFSET__"))) {
zend_ast *last = CG(ast);
while (last && last->kind == ZEND_AST_STMT_LIST) {
while (last->kind == ZEND_AST_STMT_LIST) {
zend_ast_list *list = zend_ast_get_list(last);
if (list->children == 0) {
break;
}
last = list->child[list->children-1];
}
if (last && last->kind == ZEND_AST_HALT_COMPILER) {
if (last->kind == ZEND_AST_HALT_COMPILER) {
result->op_type = IS_CONST;
ZVAL_LONG(&result->u.constant, Z_LVAL_P(zend_ast_get_zval(last->child[0])));
zend_string_release_ex(resolved_name, 0);
@@ -8129,7 +8066,9 @@ void zend_compile_const_expr_magic_const(zend_ast **ast_ptr) /* {{{ */
zend_ast *ast = *ast_ptr;
/* Other cases already resolved by constant folding */
ZEND_ASSERT(ast->attr == T_CLASS_C);
ZEND_ASSERT(ast->attr == T_CLASS_C &&
CG(active_class_entry) &&
(CG(active_class_entry)->ce_flags & ZEND_ACC_TRAIT) != 0);
zend_ast_destroy(ast);
*ast_ptr = zend_ast_create(ZEND_AST_CONSTANT_CLASS);
@@ -8549,28 +8488,25 @@ void zend_eval_const_expr(zend_ast **ast_ptr) /* {{{ */
case ZEND_AST_AND:
case ZEND_AST_OR:
{
zend_bool child0_is_true, child1_is_true;
zend_eval_const_expr(&ast->child[0]);
zend_eval_const_expr(&ast->child[1]);
if (ast->child[0]->kind != ZEND_AST_ZVAL) {
int i;
for (i = 0; i <= 1; i++) {
zend_eval_const_expr(&ast->child[i]);
if (ast->child[i]->kind == ZEND_AST_ZVAL) {
if (zend_is_true(zend_ast_get_zval(ast->child[i])) == (ast->kind == ZEND_AST_OR)) {
ZVAL_BOOL(&result, ast->kind == ZEND_AST_OR);
return;
}
}
}
if (ast->child[0]->kind != ZEND_AST_ZVAL || ast->child[1]->kind != ZEND_AST_ZVAL) {
return;
}
child0_is_true = zend_is_true(zend_ast_get_zval(ast->child[0]));
if (child0_is_true == (ast->kind == ZEND_AST_OR)) {
ZVAL_BOOL(&result, ast->kind == ZEND_AST_OR);
break;
}
if (ast->child[1]->kind != ZEND_AST_ZVAL) {
return;
}
child1_is_true = zend_is_true(zend_ast_get_zval(ast->child[1]));
if (ast->kind == ZEND_AST_OR) {
ZVAL_BOOL(&result, child0_is_true || child1_is_true);
ZVAL_BOOL(&result, zend_is_true(zend_ast_get_zval(ast->child[0])) || zend_is_true(zend_ast_get_zval(ast->child[1])));
} else {
ZVAL_BOOL(&result, child0_is_true && child1_is_true);
ZVAL_BOOL(&result, zend_is_true(zend_ast_get_zval(ast->child[0])) && zend_is_true(zend_ast_get_zval(ast->child[1])));
}
break;
}
-3
View File
@@ -1048,9 +1048,6 @@ END_EXTERN_C()
/* result of compilation may be stored in file cache */
#define ZEND_COMPILE_WITH_FILE_CACHE (1<<11)
/* disable jumptable optimization for switch statements */
#define ZEND_COMPILE_NO_JUMPTABLES (1<<12)
/* The default value for CG(compiler_options) */
#define ZEND_COMPILE_DEFAULT ZEND_COMPILE_HANDLE_OP_ARRAY
+1 -3
View File
@@ -378,9 +378,7 @@ ZEND_API zval *zend_get_constant_ex(zend_string *cname, zend_class_entry *scope,
ret_constant = NULL;
} else {
if (!zend_verify_const_access(c, scope)) {
if ((flags & ZEND_FETCH_CLASS_SILENT) == 0) {
zend_throw_error(NULL, "Cannot access %s const %s::%s", zend_visibility_string(Z_ACCESS_FLAGS(c->value)), ZSTR_VAL(class_name), ZSTR_VAL(constant_name));
}
zend_throw_error(NULL, "Cannot access %s const %s::%s", zend_visibility_string(Z_ACCESS_FLAGS(c->value)), ZSTR_VAL(class_name), ZSTR_VAL(constant_name));
goto failure;
}
ret_constant = &c->value;
+3 -23
View File
@@ -36,23 +36,11 @@ static void __zend_cpuid(uint32_t func, uint32_t subfunc, zend_cpu_info *cpuinfo
}
# else
static void __zend_cpuid(uint32_t func, uint32_t subfunc, zend_cpu_info *cpuinfo) {
#if defined(__i386__) && (defined(__pic__) || defined(__PIC__))
/* PIC on i386 uses %ebx, so preserve it. */
__asm__ __volatile__ (
"pushl %%ebx\n"
"cpuid\n"
"mov %%ebx,%1\n"
"popl %%ebx"
: "=a"(cpuinfo->eax), "=r"(cpuinfo->ebx), "=c"(cpuinfo->ecx), "=d"(cpuinfo->edx)
: "a"(func), "c"(subfunc)
);
#else
__asm__ __volatile__ (
"cpuid"
: "=a"(cpuinfo->eax), "=b"(cpuinfo->ebx), "=c"(cpuinfo->ecx), "=d"(cpuinfo->edx)
: "a"(func), "c"(subfunc)
);
#endif
}
# endif
#elif defined(ZEND_WIN32) && !defined(__clang__)
@@ -77,24 +65,16 @@ void zend_cpu_startup(void)
{
if (!cpuinfo.initialized) {
zend_cpu_info ebx;
int max_feature;
cpuinfo.initialized = 1;
__zend_cpuid(0, 0, &cpuinfo);
max_feature = cpuinfo.eax;
if (max_feature == 0) {
if (cpuinfo.eax == 0) {
return;
}
__zend_cpuid(1, 0, &cpuinfo);
/* for avx2 */
if (max_feature >= 7) {
__zend_cpuid(7, 0, &ebx);
cpuinfo.ebx = ebx.ebx;
} else {
cpuinfo.ebx = 0;
}
__zend_cpuid(7, 0, &ebx);
cpuinfo.ebx = ebx.ebx;
}
}
-16
View File
@@ -100,22 +100,12 @@ typedef enum _zend_cpu_feature {
void zend_cpu_startup();
ZEND_API int zend_cpu_supports(zend_cpu_feature feature);
/* Address sanitizer is incompatible with ifunc resolvers, so exclude the
* CPU support helpers from asan.
* See also https://github.com/google/sanitizers/issues/342. */
#if __has_attribute(no_sanitize_address)
# define ZEND_NO_SANITIZE_ADDRESS __attribute__((no_sanitize_address))
#else
# define ZEND_NO_SANITIZE_ADDRESS
#endif
#if PHP_HAVE_BUILTIN_CPU_SUPPORTS
/* NOTE: you should use following inline function in
* resolver functions (ifunc), as it could be called
* before all PLT symbols are resloved. in other words,
* resolver functions should not depends any external
* functions */
ZEND_NO_SANITIZE_ADDRESS
static zend_always_inline int zend_cpu_supports_sse2() {
#if PHP_HAVE_BUILTIN_CPU_INIT
__builtin_cpu_init();
@@ -123,7 +113,6 @@ static zend_always_inline int zend_cpu_supports_sse2() {
return __builtin_cpu_supports("sse2");
}
ZEND_NO_SANITIZE_ADDRESS
static zend_always_inline int zend_cpu_supports_sse3() {
#if PHP_HAVE_BUILTIN_CPU_INIT
__builtin_cpu_init();
@@ -131,7 +120,6 @@ static zend_always_inline int zend_cpu_supports_sse3() {
return __builtin_cpu_supports("sse3");
}
ZEND_NO_SANITIZE_ADDRESS
static zend_always_inline int zend_cpu_supports_ssse3() {
#if PHP_HAVE_BUILTIN_CPU_INIT
__builtin_cpu_init();
@@ -139,7 +127,6 @@ static zend_always_inline int zend_cpu_supports_ssse3() {
return __builtin_cpu_supports("ssse3");
}
ZEND_NO_SANITIZE_ADDRESS
static zend_always_inline int zend_cpu_supports_sse41() {
#if PHP_HAVE_BUILTIN_CPU_INIT
__builtin_cpu_init();
@@ -147,7 +134,6 @@ static zend_always_inline int zend_cpu_supports_sse41() {
return __builtin_cpu_supports("sse4.1");
}
ZEND_NO_SANITIZE_ADDRESS
static zend_always_inline int zend_cpu_supports_sse42() {
#if PHP_HAVE_BUILTIN_CPU_INIT
__builtin_cpu_init();
@@ -155,7 +141,6 @@ static zend_always_inline int zend_cpu_supports_sse42() {
return __builtin_cpu_supports("sse4.2");
}
ZEND_NO_SANITIZE_ADDRESS
static zend_always_inline int zend_cpu_supports_avx() {
#if PHP_HAVE_BUILTIN_CPU_INIT
__builtin_cpu_init();
@@ -163,7 +148,6 @@ static zend_always_inline int zend_cpu_supports_avx() {
return __builtin_cpu_supports("avx");
}
ZEND_NO_SANITIZE_ADDRESS
static zend_always_inline int zend_cpu_supports_avx2() {
#if PHP_HAVE_BUILTIN_CPU_INIT
__builtin_cpu_init();
+13 -31
View File
@@ -76,15 +76,9 @@ void zend_exception_set_previous(zend_object *exception, zend_object *add_previo
zval pv, zv, rv;
zend_class_entry *base_ce;
if (!exception || !add_previous) {
if (exception == add_previous || !add_previous || !exception) {
return;
}
if (exception == add_previous) {
OBJ_RELEASE(add_previous);
return;
}
ZVAL_OBJ(&pv, add_previous);
if (!instanceof_function(Z_OBJCE(pv), zend_ce_throwable)) {
zend_error_noreturn(E_CORE_ERROR, "Previous exception must implement Throwable");
@@ -406,13 +400,11 @@ ZEND_METHOD(error_exception, __construct)
Get the file in which the exception occurred */
ZEND_METHOD(exception, getFile)
{
zval *prop, rv;
zval rv;
DEFAULT_0_PARAMS;
prop = GET_PROPERTY(getThis(), ZEND_STR_FILE);
ZVAL_DEREF(prop);
ZVAL_COPY(return_value, prop);
ZVAL_COPY(return_value, GET_PROPERTY(getThis(), ZEND_STR_FILE));
}
/* }}} */
@@ -420,13 +412,11 @@ ZEND_METHOD(exception, getFile)
Get the line in which the exception occurred */
ZEND_METHOD(exception, getLine)
{
zval *prop, rv;
zval rv;
DEFAULT_0_PARAMS;
prop = GET_PROPERTY(getThis(), ZEND_STR_LINE);
ZVAL_DEREF(prop);
ZVAL_COPY(return_value, prop);
ZVAL_COPY(return_value, GET_PROPERTY(getThis(), ZEND_STR_LINE));
}
/* }}} */
@@ -434,13 +424,11 @@ ZEND_METHOD(exception, getLine)
Get the exception message */
ZEND_METHOD(exception, getMessage)
{
zval *prop, rv;
zval rv;
DEFAULT_0_PARAMS;
prop = GET_PROPERTY(getThis(), ZEND_STR_MESSAGE);
ZVAL_DEREF(prop);
ZVAL_COPY(return_value, prop);
ZVAL_COPY(return_value, GET_PROPERTY(getThis(), ZEND_STR_MESSAGE));
}
/* }}} */
@@ -448,13 +436,11 @@ ZEND_METHOD(exception, getMessage)
Get the exception code */
ZEND_METHOD(exception, getCode)
{
zval *prop, rv;
zval rv;
DEFAULT_0_PARAMS;
prop = GET_PROPERTY(getThis(), ZEND_STR_CODE);
ZVAL_DEREF(prop);
ZVAL_COPY(return_value, prop);
ZVAL_COPY(return_value, GET_PROPERTY(getThis(), ZEND_STR_CODE));
}
/* }}} */
@@ -462,13 +448,11 @@ ZEND_METHOD(exception, getCode)
Get the stack trace for the location in which the exception occurred */
ZEND_METHOD(exception, getTrace)
{
zval *prop, rv;
zval rv;
DEFAULT_0_PARAMS;
prop = GET_PROPERTY(getThis(), ZEND_STR_TRACE);
ZVAL_DEREF(prop);
ZVAL_COPY(return_value, prop);
ZVAL_COPY(return_value, GET_PROPERTY(getThis(), ZEND_STR_TRACE));
}
/* }}} */
@@ -476,13 +460,11 @@ ZEND_METHOD(exception, getTrace)
Get the exception severity */
ZEND_METHOD(error_exception, getSeverity)
{
zval *prop, rv;
zval rv;
DEFAULT_0_PARAMS;
prop = GET_PROPERTY(getThis(), ZEND_STR_SEVERITY);
ZVAL_DEREF(prop);
ZVAL_COPY(return_value, prop);
ZVAL_COPY(return_value, GET_PROPERTY(getThis(), ZEND_STR_SEVERITY));
}
/* }}} */
+7 -21
View File
@@ -170,9 +170,9 @@ ZEND_API const zend_internal_function zend_pass_function = {
#define ZEND_VM_STACK_PAGE_SIZE (ZEND_VM_STACK_PAGE_SLOTS * sizeof(zval))
#define ZEND_VM_STACK_PAGE_ALIGNED_SIZE(size, page_size) \
#define ZEND_VM_STACK_PAGE_ALIGNED_SIZE(size) \
(((size) + ZEND_VM_STACK_HEADER_SLOTS * sizeof(zval) \
+ ((page_size) - 1)) & ~((page_size) - 1))
+ (ZEND_VM_STACK_PAGE_SIZE - 1)) & ~(ZEND_VM_STACK_PAGE_SIZE - 1))
static zend_always_inline zend_vm_stack zend_vm_stack_new_page(size_t size, zend_vm_stack prev) {
zend_vm_stack page = (zend_vm_stack)emalloc(size);
@@ -192,16 +192,6 @@ ZEND_API void zend_vm_stack_init(void)
EG(vm_stack_end) = EG(vm_stack)->end;
}
ZEND_API void zend_vm_stack_init_ex(size_t page_size)
{
/* page_size must be a power of 2 */
ZEND_ASSERT(page_size > 0 && (page_size & (page_size - 1)) == 0);
EG(vm_stack_page_size) = page_size;
EG(vm_stack) = zend_vm_stack_new_page(page_size, NULL);
EG(vm_stack_top) = EG(vm_stack)->top;
EG(vm_stack_end) = EG(vm_stack)->end;
}
ZEND_API void zend_vm_stack_destroy(void)
{
zend_vm_stack stack = EG(vm_stack);
@@ -222,7 +212,7 @@ ZEND_API void* zend_vm_stack_extend(size_t size)
stack->top = EG(vm_stack_top);
EG(vm_stack) = stack = zend_vm_stack_new_page(
EXPECTED(size < EG(vm_stack_page_size) - (ZEND_VM_STACK_HEADER_SLOTS * sizeof(zval))) ?
EG(vm_stack_page_size) : ZEND_VM_STACK_PAGE_ALIGNED_SIZE(size, EG(vm_stack_page_size)),
EG(vm_stack_page_size) : ZEND_VM_STACK_PAGE_ALIGNED_SIZE(size),
stack);
ptr = stack->top;
EG(vm_stack_top) = (void*)(((char*)ptr) + size);
@@ -3364,15 +3354,11 @@ static zend_always_inline int _zend_quick_get_constant(
is_deprecated = !zend_string_equals(c->name, Z_STR_P(access_key));
} else {
check_short_name:
/* Namespaces are always case-insensitive. Only compare shortname. */
ns_sep = zend_memrchr(ZSTR_VAL(c->name), '\\', ZSTR_LEN(c->name));
if (ns_sep) {
shortname_offset = ns_sep - ZSTR_VAL(c->name) + 1;
shortname_len = ZSTR_LEN(c->name) - shortname_offset;
} else {
shortname_offset = 0;
shortname_len = ZSTR_LEN(c->name);
}
ZEND_ASSERT(ns_sep);
/* Namespaces are always case-insensitive. Only compare shortname. */
shortname_offset = ns_sep - ZSTR_VAL(c->name) + 1;
shortname_len = ZSTR_LEN(c->name) - shortname_offset;
is_deprecated = memcmp(ZSTR_VAL(c->name) + shortname_offset, Z_STRVAL_P(orig_key - 1) + shortname_offset, shortname_len) != 0;
}
-1
View File
@@ -168,7 +168,6 @@ struct _zend_vm_stack {
#endif
ZEND_API void zend_vm_stack_init(void);
ZEND_API void zend_vm_stack_init_ex(size_t page_size);
ZEND_API void zend_vm_stack_destroy(void);
ZEND_API void* zend_vm_stack_extend(size_t size);
-4
View File
@@ -836,7 +836,6 @@ ZEND_API zend_class_entry *zend_lookup_class_ex(zend_string *name, const zval *k
zend_string *lc_name;
zend_fcall_info fcall_info;
zend_fcall_info_cache fcall_cache;
zend_class_entry *orig_fake_scope;
if (key) {
lc_name = Z_STR_P(key);
@@ -923,14 +922,11 @@ ZEND_API zend_class_entry *zend_lookup_class_ex(zend_string *name, const zval *k
fcall_cache.called_scope = NULL;
fcall_cache.object = NULL;
orig_fake_scope = EG(fake_scope);
EG(fake_scope) = NULL;
zend_exception_save();
if ((zend_call_function(&fcall_info, &fcall_cache) == SUCCESS) && !EG(exception)) {
ce = zend_hash_find_ptr(EG(class_table), lc_name);
}
zend_exception_restore();
EG(fake_scope) = orig_fake_scope;
zval_ptr_dtor(&args[0]);
zval_ptr_dtor_str(&fcall_info.function_name);
+121 -303
View File
@@ -48,7 +48,7 @@
* gc_scan_roots will be called, and each root will be called with
* gc_scan(root->ref)
*
* gc_scan checks the colors of possible members.
* gc_scan checkes the colors of possible members.
*
* If the node is marked as grey and the refcount > 0
* gc_scan_black will be called on that node to scan it's subgraph.
@@ -86,22 +86,6 @@
#define GC_GREY 0x200000
#define GC_PURPLE 0x300000
/* Debug tracing */
#if ZEND_GC_DEBUG > 1
# define GC_TRACE(format, ...) fprintf(stderr, format "\n", ##__VA_ARGS__);
# define GC_TRACE_REF(ref, format, ...) \
do { \
gc_trace_ref((zend_refcounted *) ref); \
fprintf(stderr, format "\n", ##__VA_ARGS__); \
} while (0)
# define GC_TRACE_SET_COLOR(ref, color) \
GC_TRACE_REF(ref, "->%s", gc_color_name(color))
#else
# define GC_TRACE_REF(ref, format, ...)
# define GC_TRACE_SET_COLOR(ref, new_color)
# define GC_TRACE(str)
#endif
/* GC_INFO access */
#define GC_REF_ADDRESS(ref) \
(((GC_TYPE_INFO(ref)) & (GC_ADDRESS << GC_INFO_SHIFT)) >> GC_INFO_SHIFT)
@@ -119,19 +103,16 @@
} while (0)
#define GC_REF_SET_COLOR(ref, c) do { \
GC_TRACE_SET_COLOR(ref, c); \
GC_TYPE_INFO(ref) = \
(GC_TYPE_INFO(ref) & ~(GC_COLOR << GC_INFO_SHIFT)) | \
((c) << GC_INFO_SHIFT); \
} while (0)
#define GC_REF_SET_BLACK(ref) do { \
GC_TRACE_SET_COLOR(ref, GC_BLACK); \
GC_TYPE_INFO(ref) &= ~(GC_COLOR << GC_INFO_SHIFT); \
} while (0)
#define GC_REF_SET_PURPLE(ref) do { \
GC_TRACE_SET_COLOR(ref, GC_PURPLE); \
GC_TYPE_INFO(ref) |= (GC_COLOR << GC_INFO_SHIFT); \
} while (0)
@@ -169,7 +150,7 @@
#define GC_DEFAULT_BUF_SIZE (16 * 1024)
#define GC_BUF_GROW_STEP (128 * 1024)
#define GC_MAX_UNCOMPRESSED (512 * 1024)
#define GC_MAX_UNCOMPRESSED (1024 * 1024)
#define GC_MAX_BUF_SIZE 0x40000000
#define GC_THRESHOLD_DEFAULT 10000
@@ -249,79 +230,24 @@ static zend_gc_globals gc_globals;
# define GC_BENCH_PEAK(peak, counter)
#endif
#define GC_STACK_SEGMENT_SIZE (((4096 - ZEND_MM_OVERHEAD) / sizeof(void*)) - 2)
typedef struct _gc_stack gc_stack;
struct _gc_stack {
gc_stack *prev;
gc_stack *next;
zend_refcounted *data[GC_STACK_SEGMENT_SIZE];
};
#define GC_STACK_DCL(init) \
gc_stack *_stack = init; \
size_t _top = 0;
#define GC_STACK_PUSH(ref) \
gc_stack_push(&_stack, &_top, ref);
#define GC_STACK_POP() \
gc_stack_pop(&_stack, &_top)
static zend_never_inline gc_stack* gc_stack_next(gc_stack *stack)
{
if (UNEXPECTED(!stack->next)) {
gc_stack *segment = emalloc(sizeof(gc_stack));
segment->prev = stack;
segment->next = NULL;
stack->next = segment;
}
return stack->next;
}
static zend_always_inline void gc_stack_push(gc_stack **stack, size_t *top, zend_refcounted *ref)
{
if (UNEXPECTED(*top == GC_STACK_SEGMENT_SIZE)) {
(*stack) = gc_stack_next(*stack);
(*top) = 0;
}
(*stack)->data[(*top)++] = ref;
}
static zend_always_inline zend_refcounted* gc_stack_pop(gc_stack **stack, size_t *top)
{
if (UNEXPECTED((*top) == 0)) {
if (!(*stack)->prev) {
return NULL;
} else {
(*stack) = (*stack)->prev;
(*top) = GC_STACK_SEGMENT_SIZE - 1;
return (*stack)->data[GC_STACK_SEGMENT_SIZE - 1];
}
} else {
return (*stack)->data[--(*top)];
}
}
static void gc_stack_free(gc_stack *stack)
{
gc_stack *p = stack->next;
while (p) {
stack = p->next;
efree(p);
p = stack;
}
}
#if ZEND_GC_DEBUG > 1
# define GC_TRACE(format, ...) fprintf(stderr, format "\n", ##__VA_ARGS__);
# define GC_TRACE_REF(ref, format, ...) \
do { \
gc_trace_ref((zend_refcounted *) ref); \
fprintf(stderr, format "\n", ##__VA_ARGS__); \
} while (0)
# define GC_TRACE_SET_COLOR(ref, color) \
GC_TRACE_REF(ref, "->%s", gc_color_name(color))
#else
# define GC_TRACE_REF(ref, format, ...)
# define GC_TRACE_SET_COLOR(ref, new_color)
# define GC_TRACE(str)
#endif
static zend_always_inline uint32_t gc_compress(uint32_t idx)
{
if (EXPECTED(idx < GC_MAX_UNCOMPRESSED)) {
return idx;
}
return (idx % GC_MAX_UNCOMPRESSED) | GC_MAX_UNCOMPRESSED;
return idx % GC_MAX_UNCOMPRESSED;
}
static zend_always_inline gc_root_buffer* gc_decompress(zend_refcounted *ref, uint32_t idx)
@@ -680,14 +606,16 @@ ZEND_API void ZEND_FASTCALL gc_remove_from_buffer(zend_refcounted *ref)
gc_remove_from_roots(root);
}
static void gc_scan_black(zend_refcounted *ref, gc_stack *stack)
static void gc_scan_black(zend_refcounted *ref)
{
HashTable *ht = NULL;
HashTable *ht;
Bucket *p, *end;
zval *zv;
GC_STACK_DCL(stack);
tail_call:
ht = NULL;
GC_REF_SET_BLACK(ref);
if (GC_TYPE(ref) == IS_OBJECT) {
zend_object_get_gc_t get_gc;
zend_object *obj = (zend_object*)ref;
@@ -701,22 +629,18 @@ tail_call:
ZVAL_OBJ(&tmp, obj);
ht = get_gc(&tmp, &zv, &n);
end = zv + n;
if (EXPECTED(!ht) || UNEXPECTED(GC_REF_CHECK_COLOR(ht, GC_BLACK))) {
ht = NULL;
if (!n) goto next;
if (EXPECTED(!ht)) {
if (!n) return;
while (!Z_REFCOUNTED_P(--end)) {
if (zv == end) goto next;
if (zv == end) return;
}
} else {
GC_REF_SET_BLACK(ht);
}
while (zv != end) {
if (Z_REFCOUNTED_P(zv)) {
ref = Z_COUNTED_P(zv);
GC_ADDREF(ref);
if (!GC_REF_CHECK_COLOR(ref, GC_BLACK)) {
GC_REF_SET_BLACK(ref);
GC_STACK_PUSH(ref);
gc_scan_black(ref);
}
}
zv++;
@@ -725,35 +649,33 @@ tail_call:
ref = Z_COUNTED_P(zv);
GC_ADDREF(ref);
if (!GC_REF_CHECK_COLOR(ref, GC_BLACK)) {
GC_REF_SET_BLACK(ref);
goto tail_call;
}
goto next;
return;
}
} else {
goto next;
return;
}
} else if (GC_TYPE(ref) == IS_ARRAY) {
if ((zend_array*)ref != &EG(symbol_table)) {
ht = (zend_array*)ref;
} else {
goto next;
return;
}
} else if (GC_TYPE(ref) == IS_REFERENCE) {
if (Z_REFCOUNTED(((zend_reference*)ref)->val)) {
ref = Z_COUNTED(((zend_reference*)ref)->val);
GC_ADDREF(ref);
if (!GC_REF_CHECK_COLOR(ref, GC_BLACK)) {
GC_REF_SET_BLACK(ref);
goto tail_call;
}
}
goto next;
return;
} else {
goto next;
return;
}
if (!ht->nNumUsed) goto next;
if (!ht->nNumUsed) return;
p = ht->arData;
end = p + ht->nNumUsed;
while (1) {
@@ -765,7 +687,7 @@ tail_call:
if (Z_REFCOUNTED_P(zv)) {
break;
}
if (p == end) goto next;
if (p == end) return;
}
while (p != end) {
zv = &p->val;
@@ -776,8 +698,7 @@ tail_call:
ref = Z_COUNTED_P(zv);
GC_ADDREF(ref);
if (!GC_REF_CHECK_COLOR(ref, GC_BLACK)) {
GC_REF_SET_BLACK(ref);
GC_STACK_PUSH(ref);
gc_scan_black(ref);
}
}
p++;
@@ -789,33 +710,28 @@ tail_call:
ref = Z_COUNTED_P(zv);
GC_ADDREF(ref);
if (!GC_REF_CHECK_COLOR(ref, GC_BLACK)) {
GC_REF_SET_BLACK(ref);
goto tail_call;
}
next:
ref = GC_STACK_POP();
if (ref) {
goto tail_call;
}
}
static void gc_mark_grey(zend_refcounted *ref, gc_stack *stack)
static void gc_mark_grey(zend_refcounted *ref)
{
HashTable *ht = NULL;
HashTable *ht;
Bucket *p, *end;
zval *zv;
GC_STACK_DCL(stack);
do {
tail_call:
if (!GC_REF_CHECK_COLOR(ref, GC_GREY)) {
ht = NULL;
GC_BENCH_INC(zval_marked_grey);
GC_REF_SET_COLOR(ref, GC_GREY);
if (GC_TYPE(ref) == IS_OBJECT) {
zend_object_get_gc_t get_gc;
zend_object *obj = (zend_object*)ref;
if (EXPECTED(!(OBJ_FLAGS(ref) & IS_OBJ_FREE_CALLED) &&
(get_gc = obj->handlers->get_gc) != NULL)) {
(get_gc = obj->handlers->get_gc) != NULL)) {
int n;
zval *zv, *end;
zval tmp;
@@ -823,63 +739,47 @@ static void gc_mark_grey(zend_refcounted *ref, gc_stack *stack)
ZVAL_OBJ(&tmp, obj);
ht = get_gc(&tmp, &zv, &n);
end = zv + n;
if (EXPECTED(!ht) || UNEXPECTED(GC_REF_CHECK_COLOR(ht, GC_GREY))) {
ht = NULL;
if (!n) goto next;
if (EXPECTED(!ht)) {
if (!n) return;
while (!Z_REFCOUNTED_P(--end)) {
if (zv == end) goto next;
if (zv == end) return;
}
} else {
GC_REF_SET_COLOR(ht, GC_GREY);
}
while (zv != end) {
if (Z_REFCOUNTED_P(zv)) {
ref = Z_COUNTED_P(zv);
ZEND_ASSERT(GC_REFCOUNT(ref) > 0);
GC_DELREF(ref);
if (!GC_REF_CHECK_COLOR(ref, GC_GREY)) {
GC_REF_SET_COLOR(ref, GC_GREY);
GC_STACK_PUSH(ref);
}
gc_mark_grey(ref);
}
zv++;
}
if (EXPECTED(!ht)) {
ref = Z_COUNTED_P(zv);
ZEND_ASSERT(GC_REFCOUNT(ref) > 0);
GC_DELREF(ref);
if (!GC_REF_CHECK_COLOR(ref, GC_GREY)) {
GC_REF_SET_COLOR(ref, GC_GREY);
continue;
}
goto next;
goto tail_call;
}
} else {
goto next;
return;
}
} else if (GC_TYPE(ref) == IS_ARRAY) {
if (((zend_array*)ref) == &EG(symbol_table)) {
GC_REF_SET_BLACK(ref);
goto next;
return;
} else {
ht = (zend_array*)ref;
}
} else if (GC_TYPE(ref) == IS_REFERENCE) {
if (Z_REFCOUNTED(((zend_reference*)ref)->val)) {
ref = Z_COUNTED(((zend_reference*)ref)->val);
ZEND_ASSERT(GC_REFCOUNT(ref) > 0);
GC_DELREF(ref);
if (!GC_REF_CHECK_COLOR(ref, GC_GREY)) {
GC_REF_SET_COLOR(ref, GC_GREY);
continue;
}
goto tail_call;
}
goto next;
return;
} else {
goto next;
return;
}
if (!ht->nNumUsed) goto next;
if (!ht->nNumUsed) return;
p = ht->arData;
end = p + ht->nNumUsed;
while (1) {
@@ -891,7 +791,7 @@ static void gc_mark_grey(zend_refcounted *ref, gc_stack *stack)
if (Z_REFCOUNTED_P(zv)) {
break;
}
if (p == end) goto next;
if (p == end) return;
}
while (p != end) {
zv = &p->val;
@@ -900,12 +800,8 @@ static void gc_mark_grey(zend_refcounted *ref, gc_stack *stack)
}
if (Z_REFCOUNTED_P(zv)) {
ref = Z_COUNTED_P(zv);
ZEND_ASSERT(GC_REFCOUNT(ref) > 0);
GC_DELREF(ref);
if (!GC_REF_CHECK_COLOR(ref, GC_GREY)) {
GC_REF_SET_COLOR(ref, GC_GREY);
GC_STACK_PUSH(ref);
}
gc_mark_grey(ref);
}
p++;
}
@@ -914,16 +810,9 @@ static void gc_mark_grey(zend_refcounted *ref, gc_stack *stack)
zv = Z_INDIRECT_P(zv);
}
ref = Z_COUNTED_P(zv);
ZEND_ASSERT(GC_REFCOUNT(ref) > 0);
GC_DELREF(ref);
if (!GC_REF_CHECK_COLOR(ref, GC_GREY)) {
GC_REF_SET_COLOR(ref, GC_GREY);
continue;
}
next:
ref = GC_STACK_POP();
} while (ref);
goto tail_call;
}
}
/* Two-Finger compaction algorithm */
@@ -963,7 +852,7 @@ static void gc_compact(void)
}
}
static void gc_mark_roots(gc_stack *stack)
static void gc_mark_roots(void)
{
gc_root_buffer *current, *last;
@@ -974,41 +863,31 @@ static void gc_mark_roots(gc_stack *stack)
while (current != last) {
if (GC_IS_ROOT(current->ref)) {
if (GC_REF_CHECK_COLOR(current->ref, GC_PURPLE)) {
GC_REF_SET_COLOR(current->ref, GC_GREY);
gc_mark_grey(current->ref, stack);
gc_mark_grey(current->ref);
}
}
current++;
}
}
static void gc_scan(zend_refcounted *ref, gc_stack *stack)
static void gc_scan(zend_refcounted *ref)
{
HashTable *ht = NULL;
HashTable *ht;
Bucket *p, *end;
zval *zv;
GC_STACK_DCL(stack);
tail_call:
if (GC_REF_CHECK_COLOR(ref, GC_WHITE)) {
if (GC_REF_CHECK_COLOR(ref, GC_GREY)) {
if (GC_REFCOUNT(ref) > 0) {
if (!GC_REF_CHECK_COLOR(ref, GC_BLACK)) {
GC_REF_SET_BLACK(ref);
if (UNEXPECTED(!_stack->next)) {
gc_stack_next(_stack);
}
/* Split stack and reuse the tail */
_stack->next->prev = NULL;
gc_scan_black(ref, _stack->next);
_stack->next->prev = _stack;
}
gc_scan_black(ref);
} else {
GC_REF_SET_COLOR(ref, GC_WHITE);
if (GC_TYPE(ref) == IS_OBJECT) {
zend_object_get_gc_t get_gc;
zend_object *obj = (zend_object*)ref;
if (EXPECTED(!(OBJ_FLAGS(ref) & IS_OBJ_FREE_CALLED) &&
(get_gc = obj->handlers->get_gc) != NULL)) {
(get_gc = obj->handlers->get_gc) != NULL)) {
int n;
zval *zv, *end;
zval tmp;
@@ -1016,57 +895,44 @@ tail_call:
ZVAL_OBJ(&tmp, obj);
ht = get_gc(&tmp, &zv, &n);
end = zv + n;
if (EXPECTED(!ht) || UNEXPECTED(!GC_REF_CHECK_COLOR(ht, GC_GREY))) {
ht = NULL;
if (!n) goto next;
if (EXPECTED(!ht)) {
if (!n) return;
while (!Z_REFCOUNTED_P(--end)) {
if (zv == end) goto next;
if (zv == end) return;
}
} else {
GC_REF_SET_COLOR(ht, GC_WHITE);
}
while (zv != end) {
if (Z_REFCOUNTED_P(zv)) {
ref = Z_COUNTED_P(zv);
if (GC_REF_CHECK_COLOR(ref, GC_GREY)) {
GC_REF_SET_COLOR(ref, GC_WHITE);
GC_STACK_PUSH(ref);
}
gc_scan(ref);
}
zv++;
}
if (EXPECTED(!ht)) {
ref = Z_COUNTED_P(zv);
if (GC_REF_CHECK_COLOR(ref, GC_GREY)) {
GC_REF_SET_COLOR(ref, GC_WHITE);
goto tail_call;
}
goto next;
goto tail_call;
}
} else {
goto next;
return;
}
} else if (GC_TYPE(ref) == IS_ARRAY) {
if ((zend_array*)ref == &EG(symbol_table)) {
GC_REF_SET_BLACK(ref);
goto next;
return;
} else {
ht = (zend_array*)ref;
}
} else if (GC_TYPE(ref) == IS_REFERENCE) {
if (Z_REFCOUNTED(((zend_reference*)ref)->val)) {
ref = Z_COUNTED(((zend_reference*)ref)->val);
if (GC_REF_CHECK_COLOR(ref, GC_GREY)) {
GC_REF_SET_COLOR(ref, GC_WHITE);
goto tail_call;
}
goto tail_call;
}
goto next;
return;
} else {
goto next;
return;
}
if (!ht->nNumUsed) goto next;
if (!ht->nNumUsed) return;
p = ht->arData;
end = p + ht->nNumUsed;
while (1) {
@@ -1078,7 +944,7 @@ tail_call:
if (Z_REFCOUNTED_P(zv)) {
break;
}
if (p == end) goto next;
if (p == end) return;
}
while (p != end) {
zv = &p->val;
@@ -1087,10 +953,7 @@ tail_call:
}
if (Z_REFCOUNTED_P(zv)) {
ref = Z_COUNTED_P(zv);
if (GC_REF_CHECK_COLOR(ref, GC_GREY)) {
GC_REF_SET_COLOR(ref, GC_WHITE);
GC_STACK_PUSH(ref);
}
gc_scan(ref);
}
p++;
}
@@ -1099,31 +962,19 @@ tail_call:
zv = Z_INDIRECT_P(zv);
}
ref = Z_COUNTED_P(zv);
if (GC_REF_CHECK_COLOR(ref, GC_GREY)) {
GC_REF_SET_COLOR(ref, GC_WHITE);
goto tail_call;
}
goto tail_call;
}
}
next:
ref = GC_STACK_POP();
if (ref) {
goto tail_call;
}
}
static void gc_scan_roots(gc_stack *stack)
static void gc_scan_roots(void)
{
gc_root_buffer *current = GC_IDX2PTR(GC_FIRST_ROOT);
gc_root_buffer *last = GC_IDX2PTR(GC_G(first_unused));
while (current != last) {
if (GC_IS_ROOT(current->ref)) {
if (GC_REF_CHECK_COLOR(current->ref, GC_GREY)) {
GC_REF_SET_COLOR(current->ref, GC_WHITE);
gc_scan(current->ref, stack);
}
gc_scan(current->ref);
}
current++;
}
@@ -1154,15 +1005,18 @@ static void gc_add_garbage(zend_refcounted *ref)
GC_G(num_roots)++;
}
static int gc_collect_white(zend_refcounted *ref, uint32_t *flags, gc_stack *stack)
static int gc_collect_white(zend_refcounted *ref, uint32_t *flags)
{
int count = 0;
HashTable *ht = NULL;
HashTable *ht;
Bucket *p, *end;
zval *zv;
GC_STACK_DCL(stack);
do {
tail_call:
if (GC_REF_CHECK_COLOR(ref, GC_WHITE)) {
ht = NULL;
GC_REF_SET_BLACK(ref);
/* don't count references for compatibility ??? */
if (GC_TYPE(ref) != IS_REFERENCE) {
count++;
@@ -1173,7 +1027,7 @@ static int gc_collect_white(zend_refcounted *ref, uint32_t *flags, gc_stack *sta
zend_object *obj = (zend_object*)ref;
if (EXPECTED(!(OBJ_FLAGS(ref) & IS_OBJ_FREE_CALLED) &&
(get_gc = obj->handlers->get_gc) != NULL)) {
(get_gc = obj->handlers->get_gc) != NULL)) {
int n;
zval *zv, *end;
zval tmp;
@@ -1183,34 +1037,28 @@ static int gc_collect_white(zend_refcounted *ref, uint32_t *flags, gc_stack *sta
gc_add_garbage(ref);
}
if (obj->handlers->dtor_obj &&
((obj->handlers->dtor_obj != zend_objects_destroy_object) ||
(obj->ce->destructor != NULL))) {
((obj->handlers->dtor_obj != zend_objects_destroy_object) ||
(obj->ce->destructor != NULL))) {
*flags |= GC_HAS_DESTRUCTORS;
}
ZVAL_OBJ(&tmp, obj);
ht = get_gc(&tmp, &zv, &n);
end = zv + n;
if (EXPECTED(!ht) || UNEXPECTED(GC_REF_CHECK_COLOR(ht, GC_BLACK))) {
ht = NULL;
if (!n) goto next;
if (EXPECTED(!ht)) {
if (!n) return count;
while (!Z_REFCOUNTED_P(--end)) {
/* count non-refcounted for compatibility ??? */
if (Z_TYPE_P(zv) != IS_UNDEF) {
count++;
}
if (zv == end) goto next;
if (zv == end) return count;
}
} else {
GC_REF_SET_BLACK(ht);
}
while (zv != end) {
if (Z_REFCOUNTED_P(zv)) {
ref = Z_COUNTED_P(zv);
GC_ADDREF(ref);
if (GC_REF_CHECK_COLOR(ref, GC_WHITE)) {
GC_REF_SET_BLACK(ref);
GC_STACK_PUSH(ref);
}
count += gc_collect_white(ref, flags);
/* count non-refcounted for compatibility ??? */
} else if (Z_TYPE_P(zv) != IS_UNDEF) {
count++;
@@ -1220,14 +1068,10 @@ static int gc_collect_white(zend_refcounted *ref, uint32_t *flags, gc_stack *sta
if (EXPECTED(!ht)) {
ref = Z_COUNTED_P(zv);
GC_ADDREF(ref);
if (GC_REF_CHECK_COLOR(ref, GC_WHITE)) {
GC_REF_SET_BLACK(ref);
continue;
}
goto next;
goto tail_call;
}
} else {
goto next;
return count;
}
} else if (GC_TYPE(ref) == IS_ARRAY) {
/* optimization: color is GC_BLACK (0) */
@@ -1239,17 +1083,14 @@ static int gc_collect_white(zend_refcounted *ref, uint32_t *flags, gc_stack *sta
if (Z_REFCOUNTED(((zend_reference*)ref)->val)) {
ref = Z_COUNTED(((zend_reference*)ref)->val);
GC_ADDREF(ref);
if (GC_REF_CHECK_COLOR(ref, GC_WHITE)) {
GC_REF_SET_BLACK(ref);
continue;
}
goto tail_call;
}
goto next;
return count;
} else {
goto next;
return count;
}
if (!ht->nNumUsed) goto next;
if (!ht->nNumUsed) return count;
p = ht->arData;
end = p + ht->nNumUsed;
while (1) {
@@ -1265,7 +1106,7 @@ static int gc_collect_white(zend_refcounted *ref, uint32_t *flags, gc_stack *sta
if (Z_TYPE_P(zv) != IS_UNDEF) {
count++;
}
if (p == end) goto next;
if (p == end) return count;
}
while (p != end) {
zv = &p->val;
@@ -1275,10 +1116,7 @@ static int gc_collect_white(zend_refcounted *ref, uint32_t *flags, gc_stack *sta
if (Z_REFCOUNTED_P(zv)) {
ref = Z_COUNTED_P(zv);
GC_ADDREF(ref);
if (GC_REF_CHECK_COLOR(ref, GC_WHITE)) {
GC_REF_SET_BLACK(ref);
GC_STACK_PUSH(ref);
}
count += gc_collect_white(ref, flags);
/* count non-refcounted for compatibility ??? */
} else if (Z_TYPE_P(zv) != IS_UNDEF) {
count++;
@@ -1291,19 +1129,12 @@ static int gc_collect_white(zend_refcounted *ref, uint32_t *flags, gc_stack *sta
}
ref = Z_COUNTED_P(zv);
GC_ADDREF(ref);
if (GC_REF_CHECK_COLOR(ref, GC_WHITE)) {
GC_REF_SET_BLACK(ref);
continue;
}
next:
ref = GC_STACK_POP();
} while (ref);
goto tail_call;
}
return count;
}
static int gc_collect_roots(uint32_t *flags, gc_stack *stack)
static int gc_collect_roots(uint32_t *flags)
{
uint32_t idx, end;
zend_refcounted *ref;
@@ -1334,8 +1165,7 @@ static int gc_collect_roots(uint32_t *flags, gc_stack *stack)
ZEND_ASSERT(GC_IS_ROOT(ref));
current->ref = GC_MAKE_GARBAGE(ref);
if (GC_REF_CHECK_COLOR(ref, GC_WHITE)) {
GC_REF_SET_BLACK(ref);
count += gc_collect_white(ref, flags, stack);
count += gc_collect_white(ref, flags);
}
idx++;
}
@@ -1350,24 +1180,16 @@ static void gc_remove_nested_data_from_buffer(zend_refcounted *ref, gc_root_buff
zval *zv;
tail_call:
do {
if (root ||
(GC_REF_ADDRESS(ref) != 0 &&
GC_REF_CHECK_COLOR(ref, GC_BLACK))) {
GC_TRACE_REF(ref, "removing from buffer");
if (root) {
GC_TRACE_REF(ref, "removing from buffer");
gc_remove_from_roots(root);
GC_REF_SET_INFO(ref, 0);
root = NULL;
} else if (GC_REF_ADDRESS(ref) != 0
&& GC_REF_CHECK_COLOR(ref, GC_BLACK)) {
GC_TRACE_REF(ref, "removing from buffer");
GC_REMOVE_FROM_BUFFER(ref);
} else if (GC_TYPE(ref) == IS_REFERENCE) {
if (Z_REFCOUNTED(((zend_reference*)ref)->val)) {
ref = Z_COUNTED(((zend_reference*)ref)->val);
goto tail_call;
}
return;
} else {
return;
GC_REMOVE_FROM_BUFFER(ref);
}
if (GC_TYPE(ref) == IS_OBJECT) {
@@ -1400,15 +1222,17 @@ tail_call:
ref = Z_COUNTED_P(zv);
goto tail_call;
}
if (GC_REF_ADDRESS(ht) != 0 && GC_REF_CHECK_COLOR(ht, GC_BLACK)) {
GC_TRACE_REF(ht, "removing from buffer");
GC_REMOVE_FROM_BUFFER(ht);
}
} else {
return;
}
} else if (GC_TYPE(ref) == IS_ARRAY) {
ht = (zend_array*)ref;
} else if (GC_TYPE(ref) == IS_REFERENCE) {
if (Z_REFCOUNTED(((zend_reference*)ref)->val)) {
ref = Z_COUNTED(((zend_reference*)ref)->val);
goto tail_call;
}
return;
} else {
return;
}
@@ -1444,7 +1268,7 @@ tail_call:
}
ref = Z_COUNTED_P(zv);
goto tail_call;
} while (0);
}
}
ZEND_API int zend_gc_collect_cycles(void)
@@ -1456,10 +1280,6 @@ ZEND_API int zend_gc_collect_cycles(void)
zend_refcounted *p;
uint32_t gc_flags = 0;
uint32_t idx, end;
gc_stack stack;
stack.prev = NULL;
stack.next = NULL;
if (GC_G(gc_active)) {
return 0;
@@ -1470,14 +1290,12 @@ ZEND_API int zend_gc_collect_cycles(void)
GC_G(gc_active) = 1;
GC_TRACE("Marking roots");
gc_mark_roots(&stack);
gc_mark_roots();
GC_TRACE("Scanning roots");
gc_scan_roots(&stack);
gc_scan_roots();
GC_TRACE("Collecting roots");
count = gc_collect_roots(&gc_flags, &stack);
gc_stack_free(&stack);
count = gc_collect_roots(&gc_flags);
if (!GC_G(num_roots)) {
/* nothing to free */
+21 -20
View File
@@ -96,18 +96,16 @@ ZEND_API zend_execute_data* zend_generator_freeze_call_stack(zend_execute_data *
/* }}} */
static void zend_generator_cleanup_unfinished_execution(
zend_generator *generator, zend_execute_data *execute_data, uint32_t catch_op_num) /* {{{ */
zend_generator *generator, uint32_t catch_op_num) /* {{{ */
{
zend_execute_data *execute_data = generator->execute_data;
if (execute_data->opline != execute_data->func->op_array.opcodes) {
/* -1 required because we want the last run opcode, not the next to-be-run one. */
uint32_t op_num = execute_data->opline - execute_data->func->op_array.opcodes - 1;
if (UNEXPECTED(generator->frozen_call_stack)) {
/* Temporarily restore generator->execute_data if it has been NULLed out already. */
zend_execute_data *save_ex = generator->execute_data;
generator->execute_data = execute_data;
zend_generator_restore_call_stack(generator);
generator->execute_data = save_ex;
}
zend_cleanup_unfinished_execution(execute_data, op_num, catch_op_num);
}
@@ -118,9 +116,6 @@ ZEND_API void zend_generator_close(zend_generator *generator, zend_bool finished
{
if (EXPECTED(generator->execute_data)) {
zend_execute_data *execute_data = generator->execute_data;
/* Null out execute_data early, to prevent double frees if GC runs while we're
* already cleaning up execute_data. */
generator->execute_data = NULL;
if (EX_CALL_INFO() & ZEND_CALL_HAS_SYMBOL_TABLE) {
zend_clean_and_cache_symbol_table(execute_data->symbol_table);
@@ -128,7 +123,8 @@ ZEND_API void zend_generator_close(zend_generator *generator, zend_bool finished
/* always free the CV's, in the symtable are only not-free'd IS_INDIRECT's */
zend_free_compiled_variables(execute_data);
if (EX_CALL_INFO() & ZEND_CALL_RELEASE_THIS) {
if ((EX_CALL_INFO() & ZEND_CALL_RELEASE_THIS) &&
EXPECTED(GC_TYPE(Z_OBJ(execute_data->This)) == IS_OBJECT)) {
OBJ_RELEASE(Z_OBJ(execute_data->This));
}
@@ -139,16 +135,17 @@ ZEND_API void zend_generator_close(zend_generator *generator, zend_bool finished
return;
}
zend_vm_stack_free_extra_args(execute_data);
zend_vm_stack_free_extra_args(generator->execute_data);
/* Some cleanups are only necessary if the generator was closed
* before it could finish execution (reach a return statement). */
if (UNEXPECTED(!finished_execution)) {
zend_generator_cleanup_unfinished_execution(generator, execute_data, 0);
zend_generator_cleanup_unfinished_execution(generator, 0);
}
/* Free closure object */
if (EX_CALL_INFO() & ZEND_CALL_CLOSURE) {
if ((EX_CALL_INFO() & ZEND_CALL_CLOSURE) &&
EXPECTED(GC_TYPE(ZEND_CLOSURE_OBJECT(EX(func))) == IS_OBJECT)) {
OBJ_RELEASE(ZEND_CLOSURE_OBJECT(EX(func)));
}
@@ -158,7 +155,8 @@ ZEND_API void zend_generator_close(zend_generator *generator, zend_bool finished
generator->gc_buffer = NULL;
}
efree(execute_data);
efree(generator->execute_data);
generator->execute_data = NULL;
}
}
/* }}} */
@@ -219,7 +217,7 @@ static void zend_generator_dtor_storage(zend_object *object) /* {{{ */
if (finally_op_num) {
zval *fast_call;
zend_generator_cleanup_unfinished_execution(generator, ex, finally_op_num);
zend_generator_cleanup_unfinished_execution(generator, finally_op_num);
fast_call = ZEND_CALL_VAR(ex, ex->func->op_array.opcodes[finally_op_end].op1.var);
Z_OBJ_P(fast_call) = EG(exception);
@@ -253,6 +251,10 @@ static void zend_generator_free_storage(zend_object *object) /* {{{ */
}
zend_object_std_dtor(&generator->std);
if (generator->iterator) {
zend_iterator_dtor(generator->iterator);
}
}
/* }}} */
@@ -271,7 +273,7 @@ static uint32_t calc_gc_buffer_size(zend_generator *generator) /* {{{ */
if (EX_CALL_INFO() & ZEND_CALL_FREE_EXTRA_ARGS) {
size += EX_NUM_ARGS() - op_array->num_args;
}
size += (EX_CALL_INFO() & ZEND_CALL_RELEASE_THIS) != 0; /* $this */
size += Z_TYPE(execute_data->This) == IS_OBJECT; /* $this */
size += (EX_CALL_INFO() & ZEND_CALL_CLOSURE) != 0; /* Closure object */
/* Live vars */
@@ -352,7 +354,7 @@ static HashTable *zend_generator_get_gc(zval *object, zval **table, int *n) /* {
}
}
if (EX_CALL_INFO() & ZEND_CALL_RELEASE_THIS) {
if (Z_TYPE(execute_data->This) == IS_OBJECT) {
ZVAL_OBJ(gc_buffer++, Z_OBJ(execute_data->This));
}
if (EX_CALL_INFO() & ZEND_CALL_CLOSURE) {
@@ -823,10 +825,9 @@ try_again:
if (UNEXPECTED(EG(exception) != NULL)) {
if (generator == orig_generator) {
zend_generator_close(generator, 0);
if (!EG(current_execute_data)) {
zend_throw_exception_internal(NULL);
} else if (EG(current_execute_data)->func &&
ZEND_USER_CODE(EG(current_execute_data)->func->common.type)) {
if (EG(current_execute_data) &&
EG(current_execute_data)->func &&
ZEND_USER_CODE(EG(current_execute_data)->func->common.type)) {
zend_rethrow_exception(EG(current_execute_data));
}
} else {
+2 -3
View File
@@ -233,9 +233,8 @@ struct _zend_executor_globals {
void *reserved[ZEND_MAX_RESERVED_RESOURCES];
};
#define EG_FLAGS_INITIAL (0)
#define EG_FLAGS_IN_SHUTDOWN (1<<0)
#define EG_FLAGS_OBJECT_STORE_NO_REUSE (1<<1)
#define EG_FLAGS_INITIAL 0x00
#define EG_FLAGS_IN_SHUTDOWN 0x01
struct _zend_ini_scanner_globals {
zend_file_handle *yy_in;
+56 -31
View File
@@ -64,7 +64,7 @@ static void _zend_is_inconsistent(const HashTable *ht, const char *file, int lin
zend_output_debug_string(1, "%s(%d) : ht=%p is inconsistent", file, line, ht);
break;
}
ZEND_ASSERT(0);
zend_bailout();
}
#define IS_CONSISTENT(a) _zend_is_inconsistent(a, __FILE__, __LINE__);
#define SET_INCONSISTENT(n) do { \
@@ -377,8 +377,10 @@ ZEND_API uint32_t zend_array_count(HashTable *ht)
}
/* }}} */
static zend_always_inline HashPosition _zend_hash_get_valid_pos(const HashTable *ht, HashPosition pos)
static zend_always_inline HashPosition _zend_hash_get_first_pos(const HashTable *ht)
{
HashPosition pos = 0;
while (pos < ht->nNumUsed && Z_ISUNDEF(ht->arData[pos].val)) {
pos++;
}
@@ -387,7 +389,12 @@ static zend_always_inline HashPosition _zend_hash_get_valid_pos(const HashTable
static zend_always_inline HashPosition _zend_hash_get_current_pos(const HashTable *ht)
{
return _zend_hash_get_valid_pos(ht, ht->nInternalPointer);
HashPosition pos = ht->nInternalPointer;
if (pos == 0) {
pos = _zend_hash_get_first_pos(ht);
}
return pos;
}
ZEND_API HashPosition ZEND_FASTCALL zend_hash_get_current_pos(const HashTable *ht)
@@ -481,7 +488,6 @@ ZEND_API void ZEND_FASTCALL zend_hash_iterator_del(uint32_t idx)
if (EXPECTED(iter->ht) && EXPECTED(iter->ht != HT_POISONED_PTR)
&& EXPECTED(!HT_ITERATORS_OVERFLOW(iter->ht))) {
ZEND_ASSERT(HT_ITERATORS_COUNT(iter->ht) != 0);
HT_DEC_ITERATORS_COUNT(iter->ht);
}
iter->ht = NULL;
@@ -1071,7 +1077,6 @@ ZEND_API int ZEND_FASTCALL zend_hash_rehash(HashTable *ht)
p++;
} while (++i < ht->nNumUsed);
} else {
uint32_t old_num_used = ht->nNumUsed;
do {
if (UNEXPECTED(Z_TYPE(p->val) == IS_UNDEF)) {
uint32_t j = i;
@@ -1128,12 +1133,6 @@ ZEND_API int ZEND_FASTCALL zend_hash_rehash(HashTable *ht)
HT_HASH(ht, nIndex) = HT_IDX_TO_HASH(i);
p++;
} while (++i < ht->nNumUsed);
/* Migrate pointer to one past the end of the array to the new one past the end, so that
* newly inserted elements are picked up correctly. */
if (UNEXPECTED(HT_HAS_ITERATORS(ht))) {
_zend_hash_iterators_update(ht, old_num_used, ht->nNumUsed);
}
}
return SUCCESS;
}
@@ -1504,11 +1503,11 @@ ZEND_API void ZEND_FASTCALL zend_array_destroy(HashTable *ht)
}
} while (++p != end);
}
zend_hash_iterators_remove(ht);
SET_INCONSISTENT(HT_DESTROYED);
} else if (EXPECTED(!(HT_FLAGS(ht) & HASH_FLAG_INITIALIZED))) {
goto free_ht;
}
zend_hash_iterators_remove(ht);
SET_INCONSISTENT(HT_DESTROYED);
efree(HT_GET_DATA_ADDR(ht));
free_ht:
FREE_HASHTABLE(ht);
@@ -1929,16 +1928,15 @@ ZEND_API HashTable* ZEND_FASTCALL zend_array_dup(HashTable *source)
target->pDestructor = ZVAL_PTR_DTOR;
if (source->nNumOfElements == 0) {
uint32_t mask = HASH_FLAG_MASK & ~(HASH_FLAG_INITIALIZED|HASH_FLAG_PACKED);
HT_FLAGS(target) = (HT_FLAGS(source) & mask) | HASH_FLAG_STATIC_KEYS;
HT_FLAGS(target) = (HT_FLAGS(source) & ~(HASH_FLAG_INITIALIZED|HASH_FLAG_PACKED)) | HASH_FLAG_STATIC_KEYS;
target->nTableMask = HT_MIN_MASK;
target->nNumUsed = 0;
target->nNumOfElements = 0;
target->nNextFreeElement = source->nNextFreeElement;
target->nNextFreeElement = 0;
target->nInternalPointer = 0;
HT_SET_DATA_ADDR(target, &uninitialized_bucket);
} else if (GC_FLAGS(source) & IS_ARRAY_IMMUTABLE) {
HT_FLAGS(target) = HT_FLAGS(source) & HASH_FLAG_MASK;
HT_FLAGS(target) = HT_FLAGS(source);
target->nTableMask = source->nTableMask;
target->nNumUsed = source->nNumUsed;
target->nNumOfElements = source->nNumOfElements;
@@ -1947,7 +1945,7 @@ ZEND_API HashTable* ZEND_FASTCALL zend_array_dup(HashTable *source)
target->nInternalPointer = source->nInternalPointer;
memcpy(HT_GET_DATA_ADDR(target), HT_GET_DATA_ADDR(source), HT_USED_SIZE(source));
} else if (HT_FLAGS(source) & HASH_FLAG_PACKED) {
HT_FLAGS(target) = HT_FLAGS(source) & HASH_FLAG_MASK;
HT_FLAGS(target) = HT_FLAGS(source);
target->nTableMask = HT_MIN_MASK;
target->nNumUsed = source->nNumUsed;
target->nNumOfElements = source->nNumOfElements;
@@ -1965,7 +1963,7 @@ ZEND_API HashTable* ZEND_FASTCALL zend_array_dup(HashTable *source)
zend_array_dup_packed_elements(source, target, 1);
}
} else {
HT_FLAGS(target) = HT_FLAGS(source) & HASH_FLAG_MASK;
HT_FLAGS(target) = HT_FLAGS(source);
target->nTableMask = source->nTableMask;
target->nNextFreeElement = source->nNextFreeElement;
target->nInternalPointer =
@@ -2191,7 +2189,7 @@ ZEND_API void ZEND_FASTCALL zend_hash_internal_pointer_reset_ex(HashTable *ht, H
{
IS_CONSISTENT(ht);
HT_ASSERT(ht, &ht->nInternalPointer != pos || GC_REFCOUNT(ht) == 1);
*pos = _zend_hash_get_valid_pos(ht, 0);
*pos = _zend_hash_get_first_pos(ht);
}
@@ -2219,13 +2217,19 @@ ZEND_API void ZEND_FASTCALL zend_hash_internal_pointer_end_ex(HashTable *ht, Has
ZEND_API int ZEND_FASTCALL zend_hash_move_forward_ex(HashTable *ht, HashPosition *pos)
{
uint32_t idx;
uint32_t idx = *pos;
IS_CONSISTENT(ht);
HT_ASSERT(ht, &ht->nInternalPointer != pos || GC_REFCOUNT(ht) == 1);
idx = _zend_hash_get_valid_pos(ht, *pos);
if (idx < ht->nNumUsed) {
if (idx == 0) {
idx = _zend_hash_get_first_pos(ht);
if (idx >= ht->nNumUsed) {
*pos = idx;
return SUCCESS;
}
}
while (1) {
idx++;
if (idx >= ht->nNumUsed) {
@@ -2268,12 +2272,17 @@ ZEND_API int ZEND_FASTCALL zend_hash_move_backwards_ex(HashTable *ht, HashPositi
/* This function should be made binary safe */
ZEND_API int ZEND_FASTCALL zend_hash_get_current_key_ex(const HashTable *ht, zend_string **str_index, zend_ulong *num_index, HashPosition *pos)
{
uint32_t idx;
uint32_t idx = *pos;
Bucket *p;
IS_CONSISTENT(ht);
idx = _zend_hash_get_valid_pos(ht, *pos);
if (idx < ht->nNumUsed) {
if (idx == 0) {
idx = _zend_hash_get_first_pos(ht);
if (idx >= ht->nNumUsed) {
return HASH_KEY_NON_EXISTENT;
}
}
p = ht->arData + idx;
if (p->key) {
*str_index = p->key;
@@ -2288,14 +2297,20 @@ ZEND_API int ZEND_FASTCALL zend_hash_get_current_key_ex(const HashTable *ht, zen
ZEND_API void ZEND_FASTCALL zend_hash_get_current_key_zval_ex(const HashTable *ht, zval *key, HashPosition *pos)
{
uint32_t idx;
uint32_t idx = *pos;
Bucket *p;
IS_CONSISTENT(ht);
idx = _zend_hash_get_valid_pos(ht, *pos);
if (idx >= ht->nNumUsed) {
ZVAL_NULL(key);
} else {
if (idx == 0) {
idx = _zend_hash_get_first_pos(ht);
if (idx >= ht->nNumUsed) {
ZVAL_NULL(key);
return;
}
}
p = ht->arData + idx;
if (p->key) {
ZVAL_STR_COPY(key, p->key);
@@ -2307,12 +2322,17 @@ ZEND_API void ZEND_FASTCALL zend_hash_get_current_key_zval_ex(const HashTable *h
ZEND_API int ZEND_FASTCALL zend_hash_get_current_key_type_ex(HashTable *ht, HashPosition *pos)
{
uint32_t idx;
uint32_t idx = *pos;
Bucket *p;
IS_CONSISTENT(ht);
idx = _zend_hash_get_valid_pos(ht, *pos);
if (idx < ht->nNumUsed) {
if (idx == 0) {
idx = _zend_hash_get_first_pos(ht);
if (idx >= ht->nNumUsed) {
return HASH_KEY_NON_EXISTENT;
}
}
p = ht->arData + idx;
if (p->key) {
return HASH_KEY_IS_STRING;
@@ -2326,12 +2346,17 @@ ZEND_API int ZEND_FASTCALL zend_hash_get_current_key_type_ex(HashTable *ht, Hash
ZEND_API zval* ZEND_FASTCALL zend_hash_get_current_data_ex(HashTable *ht, HashPosition *pos)
{
uint32_t idx;
uint32_t idx = *pos;
Bucket *p;
IS_CONSISTENT(ht);
idx = _zend_hash_get_valid_pos(ht, *pos);
if (idx < ht->nNumUsed) {
if (idx == 0) {
idx = _zend_hash_get_first_pos(ht);
if (idx >= ht->nNumUsed) {
return NULL;
}
}
p = ht->arData + idx;
return &p->val;
} else {
@@ -2722,7 +2747,7 @@ convert:
{
HashTable *new_ht = zend_new_array(zend_hash_num_elements(ht));
ZEND_HASH_FOREACH_KEY_VAL_IND(ht, num_key, str_key, zv) {
ZEND_HASH_FOREACH_KEY_VAL(ht, num_key, str_key, zv) {
do {
if (Z_OPT_REFCOUNTED_P(zv)) {
if (Z_ISREF_P(zv) && Z_REFCOUNT_P(zv) == 1) {
-3
View File
@@ -40,9 +40,6 @@
#define HASH_FLAG_HAS_EMPTY_IND (1<<5)
#define HASH_FLAG_ALLOW_COW_VIOLATION (1<<6)
/* Only the low byte are real flags */
#define HASH_FLAG_MASK 0xff
#define HT_FLAGS(ht) (ht)->u.flags
#define HT_IS_PACKED(ht) \
+18 -25
View File
@@ -208,8 +208,8 @@ static int zend_do_perform_type_hint_check(const zend_function *fe, zend_arg_inf
fe_class_name = ZEND_TYPE_NAME(fe_arg_info->type);
class_name = ZSTR_VAL(fe_class_name);
class_name_len = ZSTR_LEN(fe_class_name);
if (class_name_len == sizeof("parent")-1 && !strcasecmp(class_name, "parent") && fe->common.scope && fe->common.scope->parent) {
fe_class_name = zend_string_copy(fe->common.scope->parent->name);
if (class_name_len == sizeof("parent")-1 && !strcasecmp(class_name, "parent") && proto->common.scope) {
fe_class_name = zend_string_copy(proto->common.scope->name);
} else if (class_name_len == sizeof("self")-1 && !strcasecmp(class_name, "self") && fe->common.scope) {
fe_class_name = zend_string_copy(fe->common.scope->name);
} else {
@@ -894,9 +894,6 @@ ZEND_API void zend_do_inheritance(zend_class_entry *ce, zend_class_entry *parent
}
if (UNEXPECTED(parent_ce->type != ce->type)) {
/* User class extends internal */
if (CE_STATIC_MEMBERS(parent_ce) == NULL) {
zend_class_init_statics(parent_ce);
}
if (UNEXPECTED(zend_update_class_constants(parent_ce) != SUCCESS)) {
ZEND_ASSERT(0);
}
@@ -1129,7 +1126,18 @@ static zend_bool zend_traits_method_compatibility_check(zend_function *fn, zend_
static void zend_add_magic_methods(zend_class_entry* ce, zend_string* mname, zend_function* fe) /* {{{ */
{
if (ZSTR_LEN(ce->name) != ZSTR_LEN(mname) && (ZSTR_VAL(mname)[0] != '_' || ZSTR_VAL(mname)[1] != '_')) {
if (ZSTR_LEN(ce->name) == ZSTR_LEN(mname)) {
zend_string *lowercase_name = zend_string_tolower(ce->name);
lowercase_name = zend_new_interned_string(lowercase_name);
if (!memcmp(ZSTR_VAL(mname), ZSTR_VAL(lowercase_name), ZSTR_LEN(mname))) {
if (ce->constructor && (!ce->parent || ce->constructor != ce->parent->constructor)) {
zend_error_noreturn(E_COMPILE_ERROR, "%s has colliding constructor definitions coming from traits", ZSTR_VAL(ce->name));
}
ce->constructor = fe;
fe->common.fn_flags |= ZEND_ACC_CTOR;
}
zend_string_release_ex(lowercase_name, 0);
} else if (ZSTR_VAL(mname)[0] != '_' || ZSTR_VAL(mname)[1] != '_') {
/* pass */
} else if (zend_string_equals_literal(mname, ZEND_CLONE_FUNC_NAME)) {
ce->clone = fe;
@@ -1160,17 +1168,6 @@ static void zend_add_magic_methods(zend_class_entry* ce, zend_string* mname, zen
ce->__tostring = fe;
} else if (zend_string_equals_literal(mname, ZEND_DEBUGINFO_FUNC_NAME)) {
ce->__debugInfo = fe;
} else if (ZSTR_LEN(ce->name) == ZSTR_LEN(mname)) {
zend_string *lowercase_name = zend_string_tolower(ce->name);
lowercase_name = zend_new_interned_string(lowercase_name);
if (!memcmp(ZSTR_VAL(mname), ZSTR_VAL(lowercase_name), ZSTR_LEN(mname))) {
if (ce->constructor && (!ce->parent || ce->constructor != ce->parent->constructor)) {
zend_error_noreturn(E_COMPILE_ERROR, "%s has colliding constructor definitions coming from traits", ZSTR_VAL(ce->name));
}
ce->constructor = fe;
fe->common.fn_flags |= ZEND_ACC_CTOR;
}
zend_string_release_ex(lowercase_name, 0);
}
}
/* }}} */
@@ -1595,14 +1592,10 @@ static void zend_do_traits_property_binding(zend_class_entry *ce) /* {{{ */
/* next: check for conflicts with current class */
if ((coliding_prop = zend_hash_find_ptr(&ce->properties_info, prop_name)) != NULL) {
if (coliding_prop->flags & ZEND_ACC_SHADOW) {
/* Only free if shadow is coming from direct parent,
* otherwise these weren't copied in the first place. */
if (coliding_prop->ce == ce->parent) {
zend_string_release_ex(coliding_prop->name, 0);
if (coliding_prop->doc_comment) {
zend_string_release_ex(coliding_prop->doc_comment, 0);
}
}
zend_string_release_ex(coliding_prop->name, 0);
if (coliding_prop->doc_comment) {
zend_string_release_ex(coliding_prop->doc_comment, 0);
}
zend_hash_del(&ce->properties_info, prop_name);
flags |= ZEND_ACC_CHANGED;
} else {
+17 -19
View File
@@ -46,22 +46,6 @@ int ini_parse(void);
#define ZEND_SYSTEM_INI CG(ini_parser_unbuffered_errors)
static int get_int_val(zval *op) {
switch (Z_TYPE_P(op)) {
case IS_LONG:
return Z_LVAL_P(op);
case IS_DOUBLE:
return (int)Z_DVAL_P(op);
case IS_STRING:
{
int val = atoi(Z_STRVAL_P(op));
zend_string_free(Z_STR_P(op));
return val;
}
EMPTY_SWITCH_DEFAULT_CASE()
}
}
/* {{{ zend_ini_do_op()
*/
static void zend_ini_do_op(char type, zval *result, zval *op1, zval *op2)
@@ -71,8 +55,22 @@ static void zend_ini_do_op(char type, zval *result, zval *op1, zval *op2)
int str_len;
char str_result[MAX_LENGTH_OF_LONG+1];
i_op1 = get_int_val(op1);
i_op2 = op2 ? get_int_val(op2) : 0;
if (IS_LONG == Z_TYPE_P(op1)) {
i_op1 = Z_LVAL_P(op1);
} else {
i_op1 = atoi(Z_STRVAL_P(op1));
zend_string_free(Z_STR_P(op1));
}
if (op2) {
if (IS_LONG == Z_TYPE_P(op2)) {
i_op2 = Z_LVAL_P(op2);
} else {
i_op2 = atoi(Z_STRVAL_P(op2));
zend_string_free(Z_STR_P(op2));
}
} else {
i_op2 = 0;
}
switch (type) {
case '|':
@@ -310,7 +308,7 @@ static void zval_ini_dtor(zval *zv)
%left '|' '&' '^'
%right '~' '!'
%destructor { zval_ini_dtor(&$$); } TC_RAW TC_CONSTANT TC_NUMBER TC_STRING TC_WHITESPACE TC_LABEL TC_OFFSET TC_VARNAME BOOL_TRUE BOOL_FALSE NULL_NULL cfg_var_ref constant_literal constant_string encapsed_list expr option_offset section_string_or_value string_or_value var_string_list var_string_list_section
%destructor { zval_ini_dtor(&$$); } TC_RAW TC_CONSTANT TC_NUMBER TC_STRING TC_WHITESPACE TC_LABEL TC_OFFSET TC_VARNAME BOOL_TRUE BOOL_FALSE NULL_NULL
%%
+121 -122
View File
@@ -143,14 +143,13 @@ ZEND_API zend_ini_scanner_globals ini_scanner_globals;
ZVAL_NEW_STR(retval, zend_string_init(str, len, ZEND_SYSTEM_INI))
#define RETURN_TOKEN(type, str, len) { \
if (SCNG(scanner_mode) == ZEND_INI_SCANNER_TYPED && \
(YYSTATE == STATE(ST_VALUE) || YYSTATE == STATE(ST_RAW))) {\
zend_ini_copy_typed_value(ini_lval, type, str, len); \
} else { \
zend_ini_copy_value(ini_lval, str, len); \
} \
return type; \
#define RETURN_TOKEN(type, str, len) { \
if (SCNG(scanner_mode) == ZEND_INI_SCANNER_TYPED) { \
zend_ini_copy_typed_value(ini_lval, type, str, len); \
} else { \
zend_ini_copy_value(ini_lval, str, len); \
} \
return type; \
}
static inline int convert_to_number(zval *retval, const char *str, const int str_len)
@@ -383,7 +382,7 @@ restart:
}
}
#line 387 "Zend/zend_ini_scanner.c"
#line 386 "Zend/zend_ini_scanner.c"
{
YYCTYPE yych;
unsigned int yyaccept = 0;
@@ -505,7 +504,7 @@ yy4:
yy5:
YYDEBUG(5, *YYCURSOR);
yyleng = YYCURSOR - SCNG(yy_text);
#line 482 "Zend/zend_ini_scanner.l"
#line 481 "Zend/zend_ini_scanner.l"
{ /* Get option name */
/* Eat leading whitespace */
EAT_LEADING_WHITESPACE();
@@ -515,7 +514,7 @@ yy5:
RETURN_TOKEN(TC_LABEL, yytext, yyleng);
}
#line 519 "Zend/zend_ini_scanner.c"
#line 518 "Zend/zend_ini_scanner.c"
yy6:
YYDEBUG(6, *YYCURSOR);
++YYCURSOR;
@@ -539,24 +538,24 @@ yy6:
yy8:
YYDEBUG(8, *YYCURSOR);
yyleng = YYCURSOR - SCNG(yy_text);
#line 635 "Zend/zend_ini_scanner.l"
#line 634 "Zend/zend_ini_scanner.l"
{
/* eat whitespace */
goto restart;
}
#line 548 "Zend/zend_ini_scanner.c"
#line 547 "Zend/zend_ini_scanner.c"
yy9:
YYDEBUG(9, *YYCURSOR);
++YYCURSOR;
yy10:
YYDEBUG(10, *YYCURSOR);
yyleng = YYCURSOR - SCNG(yy_text);
#line 640 "Zend/zend_ini_scanner.l"
#line 639 "Zend/zend_ini_scanner.l"
{
SCNG(lineno)++;
return END_OF_LINE;
}
#line 560 "Zend/zend_ini_scanner.c"
#line 559 "Zend/zend_ini_scanner.c"
yy11:
YYDEBUG(11, *YYCURSOR);
yych = *++YYCURSOR;
@@ -617,11 +616,11 @@ yy14:
++YYCURSOR;
YYDEBUG(15, *YYCURSOR);
yyleng = YYCURSOR - SCNG(yy_text);
#line 563 "Zend/zend_ini_scanner.l"
#line 562 "Zend/zend_ini_scanner.l"
{ /* Disallow these chars outside option values */
return yytext[0];
}
#line 625 "Zend/zend_ini_scanner.c"
#line 624 "Zend/zend_ini_scanner.c"
yy16:
YYDEBUG(16, *YYCURSOR);
++YYCURSOR;
@@ -643,7 +642,7 @@ yy18:
if (yych == ' ') goto yy18;
YYDEBUG(20, *YYCURSOR);
yyleng = YYCURSOR - SCNG(yy_text);
#line 492 "Zend/zend_ini_scanner.l"
#line 491 "Zend/zend_ini_scanner.l"
{ /* Start option value */
if (SCNG(scanner_mode) == ZEND_INI_SCANNER_RAW) {
BEGIN(ST_RAW);
@@ -652,7 +651,7 @@ yy18:
}
return '=';
}
#line 656 "Zend/zend_ini_scanner.c"
#line 655 "Zend/zend_ini_scanner.c"
yy21:
YYDEBUG(21, *YYCURSOR);
yych = *++YYCURSOR;
@@ -708,7 +707,7 @@ yy26:
++YYCURSOR;
YYDEBUG(27, *YYCURSOR);
yyleng = YYCURSOR - SCNG(yy_text);
#line 407 "Zend/zend_ini_scanner.l"
#line 406 "Zend/zend_ini_scanner.l"
{ /* Section start */
/* Enter section data lookup state */
if (SCNG(scanner_mode) == ZEND_INI_SCANNER_RAW) {
@@ -718,7 +717,7 @@ yy26:
}
return TC_SECTION;
}
#line 722 "Zend/zend_ini_scanner.c"
#line 721 "Zend/zend_ini_scanner.c"
yy28:
YYDEBUG(28, *YYCURSOR);
++YYCURSOR;
@@ -729,7 +728,7 @@ yy28:
if (yych == ' ') goto yy28;
YYDEBUG(30, *YYCURSOR);
yyleng = YYCURSOR - SCNG(yy_text);
#line 432 "Zend/zend_ini_scanner.l"
#line 431 "Zend/zend_ini_scanner.l"
{ /* Start of option with offset */
/* Eat leading whitespace */
EAT_LEADING_WHITESPACE();
@@ -742,20 +741,20 @@ yy28:
RETURN_TOKEN(TC_OFFSET, yytext, yyleng);
}
#line 746 "Zend/zend_ini_scanner.c"
#line 745 "Zend/zend_ini_scanner.c"
yy31:
YYDEBUG(31, *YYCURSOR);
++YYCURSOR;
yy32:
YYDEBUG(32, *YYCURSOR);
yyleng = YYCURSOR - SCNG(yy_text);
#line 645 "Zend/zend_ini_scanner.l"
#line 644 "Zend/zend_ini_scanner.l"
{ /* Comment */
BEGIN(INITIAL);
SCNG(lineno)++;
return END_OF_LINE;
}
#line 759 "Zend/zend_ini_scanner.c"
#line 758 "Zend/zend_ini_scanner.c"
yy33:
YYDEBUG(33, *YYCURSOR);
yych = *++YYCURSOR;
@@ -810,11 +809,11 @@ yy35:
yy36:
YYDEBUG(36, *YYCURSOR);
yyleng = YYCURSOR - SCNG(yy_text);
#line 474 "Zend/zend_ini_scanner.l"
#line 473 "Zend/zend_ini_scanner.l"
{ /* FALSE value (when used outside option value/offset this causes parse error!)*/
RETURN_TOKEN(BOOL_FALSE, "", 0);
}
#line 818 "Zend/zend_ini_scanner.c"
#line 817 "Zend/zend_ini_scanner.c"
yy37:
YYDEBUG(37, *YYCURSOR);
yych = *++YYCURSOR;
@@ -871,11 +870,11 @@ yy39:
yy41:
YYDEBUG(41, *YYCURSOR);
yyleng = YYCURSOR - SCNG(yy_text);
#line 470 "Zend/zend_ini_scanner.l"
#line 469 "Zend/zend_ini_scanner.l"
{ /* TRUE value (when used outside option value/offset this causes parse error!) */
RETURN_TOKEN(BOOL_TRUE, "1", 1);
}
#line 879 "Zend/zend_ini_scanner.c"
#line 878 "Zend/zend_ini_scanner.c"
yy42:
YYDEBUG(42, *YYCURSOR);
yych = *++YYCURSOR;
@@ -1022,11 +1021,11 @@ yy54:
yy56:
YYDEBUG(56, *YYCURSOR);
yyleng = YYCURSOR - SCNG(yy_text);
#line 478 "Zend/zend_ini_scanner.l"
#line 477 "Zend/zend_ini_scanner.l"
{
RETURN_TOKEN(NULL_NULL, "", 0);
}
#line 1030 "Zend/zend_ini_scanner.c"
#line 1029 "Zend/zend_ini_scanner.c"
yy57:
YYDEBUG(57, *YYCURSOR);
++YYCURSOR;
@@ -1135,11 +1134,11 @@ yy62:
yy63:
YYDEBUG(63, *YYCURSOR);
yyleng = YYCURSOR - SCNG(yy_text);
#line 581 "Zend/zend_ini_scanner.l"
#line 580 "Zend/zend_ini_scanner.l"
{ /* Get rest as section/offset value */
RETURN_TOKEN(TC_STRING, yytext, yyleng);
}
#line 1143 "Zend/zend_ini_scanner.c"
#line 1142 "Zend/zend_ini_scanner.c"
yy64:
YYDEBUG(64, *YYCURSOR);
yyaccept = 0;
@@ -1179,22 +1178,22 @@ yy66:
yy67:
YYDEBUG(67, *YYCURSOR);
yyleng = YYCURSOR - SCNG(yy_text);
#line 656 "Zend/zend_ini_scanner.l"
#line 655 "Zend/zend_ini_scanner.l"
{
return 0;
}
#line 1187 "Zend/zend_ini_scanner.c"
#line 1186 "Zend/zend_ini_scanner.c"
yy68:
YYDEBUG(68, *YYCURSOR);
++YYCURSOR;
YYDEBUG(69, *YYCURSOR);
yyleng = YYCURSOR - SCNG(yy_text);
#line 585 "Zend/zend_ini_scanner.l"
#line 584 "Zend/zend_ini_scanner.l"
{ /* Double quoted '"' string start */
yy_push_state(ST_DOUBLE_QUOTES);
return '"';
}
#line 1198 "Zend/zend_ini_scanner.c"
#line 1197 "Zend/zend_ini_scanner.c"
yy70:
YYDEBUG(70, *YYCURSOR);
yych = *++YYCURSOR;
@@ -1259,11 +1258,11 @@ yy73:
yy75:
YYDEBUG(75, *YYCURSOR);
yyleng = YYCURSOR - SCNG(yy_text);
#line 559 "Zend/zend_ini_scanner.l"
#line 558 "Zend/zend_ini_scanner.l"
{ /* Get number option value as string */
RETURN_TOKEN(TC_NUMBER, yytext, yyleng);
}
#line 1267 "Zend/zend_ini_scanner.c"
#line 1266 "Zend/zend_ini_scanner.c"
yy76:
YYDEBUG(76, *YYCURSOR);
yyaccept = 2;
@@ -1296,11 +1295,11 @@ yy76:
yy78:
YYDEBUG(78, *YYCURSOR);
yyleng = YYCURSOR - SCNG(yy_text);
#line 555 "Zend/zend_ini_scanner.l"
#line 554 "Zend/zend_ini_scanner.l"
{ /* Get constant option value */
RETURN_TOKEN(TC_CONSTANT, yytext, yyleng);
}
#line 1304 "Zend/zend_ini_scanner.c"
#line 1303 "Zend/zend_ini_scanner.c"
yy79:
YYDEBUG(79, *YYCURSOR);
++YYCURSOR;
@@ -1312,12 +1311,12 @@ yy80:
++YYCURSOR;
YYDEBUG(81, *YYCURSOR);
yyleng = YYCURSOR - SCNG(yy_text);
#line 445 "Zend/zend_ini_scanner.l"
#line 444 "Zend/zend_ini_scanner.l"
{ /* End of section or an option offset */
BEGIN(INITIAL);
return ']';
}
#line 1321 "Zend/zend_ini_scanner.c"
#line 1320 "Zend/zend_ini_scanner.c"
yy82:
YYDEBUG(82, *YYCURSOR);
++YYCURSOR;
@@ -1357,12 +1356,12 @@ yy86:
++YYCURSOR;
YYDEBUG(87, *YYCURSOR);
yyleng = YYCURSOR - SCNG(yy_text);
#line 450 "Zend/zend_ini_scanner.l"
#line 449 "Zend/zend_ini_scanner.l"
{ /* Variable start */
yy_push_state(ST_VARNAME);
return TC_DOLLAR_CURLY;
}
#line 1366 "Zend/zend_ini_scanner.c"
#line 1365 "Zend/zend_ini_scanner.c"
yy88:
YYDEBUG(88, *YYCURSOR);
++YYCURSOR;
@@ -1416,7 +1415,7 @@ yy92:
++YYCURSOR;
YYDEBUG(93, *YYCURSOR);
yyleng = YYCURSOR - SCNG(yy_text);
#line 417 "Zend/zend_ini_scanner.l"
#line 416 "Zend/zend_ini_scanner.l"
{ /* Raw string */
/* Eat leading and trailing single quotes */
if (yytext[0] == '\'' && yytext[yyleng - 1] == '\'') {
@@ -1425,7 +1424,7 @@ yy92:
}
RETURN_TOKEN(TC_RAW, yytext, yyleng);
}
#line 1429 "Zend/zend_ini_scanner.c"
#line 1428 "Zend/zend_ini_scanner.c"
}
/* *********************************** */
yyc_ST_SECTION_VALUE:
@@ -1525,11 +1524,11 @@ yy97:
yy98:
YYDEBUG(98, *YYCURSOR);
yyleng = YYCURSOR - SCNG(yy_text);
#line 581 "Zend/zend_ini_scanner.l"
#line 580 "Zend/zend_ini_scanner.l"
{ /* Get rest as section/offset value */
RETURN_TOKEN(TC_STRING, yytext, yyleng);
}
#line 1533 "Zend/zend_ini_scanner.c"
#line 1532 "Zend/zend_ini_scanner.c"
yy99:
YYDEBUG(99, *YYCURSOR);
yyaccept = 0;
@@ -1569,22 +1568,22 @@ yy101:
yy102:
YYDEBUG(102, *YYCURSOR);
yyleng = YYCURSOR - SCNG(yy_text);
#line 656 "Zend/zend_ini_scanner.l"
#line 655 "Zend/zend_ini_scanner.l"
{
return 0;
}
#line 1577 "Zend/zend_ini_scanner.c"
#line 1576 "Zend/zend_ini_scanner.c"
yy103:
YYDEBUG(103, *YYCURSOR);
++YYCURSOR;
YYDEBUG(104, *YYCURSOR);
yyleng = YYCURSOR - SCNG(yy_text);
#line 585 "Zend/zend_ini_scanner.l"
#line 584 "Zend/zend_ini_scanner.l"
{ /* Double quoted '"' string start */
yy_push_state(ST_DOUBLE_QUOTES);
return '"';
}
#line 1588 "Zend/zend_ini_scanner.c"
#line 1587 "Zend/zend_ini_scanner.c"
yy105:
YYDEBUG(105, *YYCURSOR);
yych = *++YYCURSOR;
@@ -1649,11 +1648,11 @@ yy108:
yy110:
YYDEBUG(110, *YYCURSOR);
yyleng = YYCURSOR - SCNG(yy_text);
#line 559 "Zend/zend_ini_scanner.l"
#line 558 "Zend/zend_ini_scanner.l"
{ /* Get number option value as string */
RETURN_TOKEN(TC_NUMBER, yytext, yyleng);
}
#line 1657 "Zend/zend_ini_scanner.c"
#line 1656 "Zend/zend_ini_scanner.c"
yy111:
YYDEBUG(111, *YYCURSOR);
yyaccept = 2;
@@ -1686,11 +1685,11 @@ yy111:
yy113:
YYDEBUG(113, *YYCURSOR);
yyleng = YYCURSOR - SCNG(yy_text);
#line 555 "Zend/zend_ini_scanner.l"
#line 554 "Zend/zend_ini_scanner.l"
{ /* Get constant option value */
RETURN_TOKEN(TC_CONSTANT, yytext, yyleng);
}
#line 1694 "Zend/zend_ini_scanner.c"
#line 1693 "Zend/zend_ini_scanner.c"
yy114:
YYDEBUG(114, *YYCURSOR);
++YYCURSOR;
@@ -1714,13 +1713,13 @@ yy115:
yy117:
YYDEBUG(117, *YYCURSOR);
yyleng = YYCURSOR - SCNG(yy_text);
#line 426 "Zend/zend_ini_scanner.l"
#line 425 "Zend/zend_ini_scanner.l"
{ /* End of section */
BEGIN(INITIAL);
SCNG(lineno)++;
return ']';
}
#line 1724 "Zend/zend_ini_scanner.c"
#line 1723 "Zend/zend_ini_scanner.c"
yy118:
YYDEBUG(118, *YYCURSOR);
++YYCURSOR;
@@ -1760,12 +1759,12 @@ yy122:
++YYCURSOR;
YYDEBUG(123, *YYCURSOR);
yyleng = YYCURSOR - SCNG(yy_text);
#line 450 "Zend/zend_ini_scanner.l"
#line 449 "Zend/zend_ini_scanner.l"
{ /* Variable start */
yy_push_state(ST_VARNAME);
return TC_DOLLAR_CURLY;
}
#line 1769 "Zend/zend_ini_scanner.c"
#line 1768 "Zend/zend_ini_scanner.c"
yy124:
YYDEBUG(124, *YYCURSOR);
++YYCURSOR;
@@ -1828,7 +1827,7 @@ yy130:
++YYCURSOR;
YYDEBUG(131, *YYCURSOR);
yyleng = YYCURSOR - SCNG(yy_text);
#line 417 "Zend/zend_ini_scanner.l"
#line 416 "Zend/zend_ini_scanner.l"
{ /* Raw string */
/* Eat leading and trailing single quotes */
if (yytext[0] == '\'' && yytext[yyleng - 1] == '\'') {
@@ -1837,7 +1836,7 @@ yy130:
}
RETURN_TOKEN(TC_RAW, yytext, yyleng);
}
#line 1841 "Zend/zend_ini_scanner.c"
#line 1840 "Zend/zend_ini_scanner.c"
}
/* *********************************** */
yyc_ST_VALUE:
@@ -1973,12 +1972,12 @@ yy134:
yy135:
YYDEBUG(135, *YYCURSOR);
yyleng = YYCURSOR - SCNG(yy_text);
#line 651 "Zend/zend_ini_scanner.l"
#line 650 "Zend/zend_ini_scanner.l"
{ /* End of option value (if EOF is reached before EOL */
BEGIN(INITIAL);
return END_OF_LINE;
}
#line 1982 "Zend/zend_ini_scanner.c"
#line 1981 "Zend/zend_ini_scanner.c"
yy136:
YYDEBUG(136, *YYCURSOR);
yyaccept = 0;
@@ -1995,11 +1994,11 @@ yy137:
yy138:
YYDEBUG(138, *YYCURSOR);
yyleng = YYCURSOR - SCNG(yy_text);
#line 577 "Zend/zend_ini_scanner.l"
#line 576 "Zend/zend_ini_scanner.l"
{ /* Get everything else as option/offset value */
RETURN_TOKEN(TC_STRING, yytext, yyleng);
}
#line 2003 "Zend/zend_ini_scanner.c"
#line 2002 "Zend/zend_ini_scanner.c"
yy139:
YYDEBUG(139, *YYCURSOR);
++YYCURSOR;
@@ -2023,24 +2022,24 @@ yy139:
yy141:
YYDEBUG(141, *YYCURSOR);
yyleng = YYCURSOR - SCNG(yy_text);
#line 631 "Zend/zend_ini_scanner.l"
#line 630 "Zend/zend_ini_scanner.l"
{
RETURN_TOKEN(TC_WHITESPACE, yytext, yyleng);
}
#line 2031 "Zend/zend_ini_scanner.c"
#line 2030 "Zend/zend_ini_scanner.c"
yy142:
YYDEBUG(142, *YYCURSOR);
++YYCURSOR;
yy143:
YYDEBUG(143, *YYCURSOR);
yyleng = YYCURSOR - SCNG(yy_text);
#line 549 "Zend/zend_ini_scanner.l"
#line 548 "Zend/zend_ini_scanner.l"
{ /* End of option value */
BEGIN(INITIAL);
SCNG(lineno)++;
return END_OF_LINE;
}
#line 2044 "Zend/zend_ini_scanner.c"
#line 2043 "Zend/zend_ini_scanner.c"
yy144:
YYDEBUG(144, *YYCURSOR);
yych = *++YYCURSOR;
@@ -2056,22 +2055,22 @@ yy145:
if (yych == ' ') goto yy145;
YYDEBUG(147, *YYCURSOR);
yyleng = YYCURSOR - SCNG(yy_text);
#line 567 "Zend/zend_ini_scanner.l"
#line 566 "Zend/zend_ini_scanner.l"
{ /* Boolean operators */
return yytext[0];
}
#line 2064 "Zend/zend_ini_scanner.c"
#line 2063 "Zend/zend_ini_scanner.c"
yy148:
YYDEBUG(148, *YYCURSOR);
++YYCURSOR;
YYDEBUG(149, *YYCURSOR);
yyleng = YYCURSOR - SCNG(yy_text);
#line 585 "Zend/zend_ini_scanner.l"
#line 584 "Zend/zend_ini_scanner.l"
{ /* Double quoted '"' string start */
yy_push_state(ST_DOUBLE_QUOTES);
return '"';
}
#line 2075 "Zend/zend_ini_scanner.c"
#line 2074 "Zend/zend_ini_scanner.c"
yy150:
YYDEBUG(150, *YYCURSOR);
yych = *++YYCURSOR;
@@ -2145,11 +2144,11 @@ yy153:
yy155:
YYDEBUG(155, *YYCURSOR);
yyleng = YYCURSOR - SCNG(yy_text);
#line 559 "Zend/zend_ini_scanner.l"
#line 558 "Zend/zend_ini_scanner.l"
{ /* Get number option value as string */
RETURN_TOKEN(TC_NUMBER, yytext, yyleng);
}
#line 2153 "Zend/zend_ini_scanner.c"
#line 2152 "Zend/zend_ini_scanner.c"
yy156:
YYDEBUG(156, *YYCURSOR);
++YYCURSOR;
@@ -2166,13 +2165,13 @@ yy158:
++YYCURSOR;
YYDEBUG(159, *YYCURSOR);
yyleng = YYCURSOR - SCNG(yy_text);
#line 571 "Zend/zend_ini_scanner.l"
#line 570 "Zend/zend_ini_scanner.l"
{ /* Make = used in option value to trigger error */
yyless(0);
BEGIN(INITIAL);
return END_OF_LINE;
}
#line 2176 "Zend/zend_ini_scanner.c"
#line 2175 "Zend/zend_ini_scanner.c"
yy160:
YYDEBUG(160, *YYCURSOR);
yyaccept = 2;
@@ -2219,11 +2218,11 @@ yy160:
yy162:
YYDEBUG(162, *YYCURSOR);
yyleng = YYCURSOR - SCNG(yy_text);
#line 555 "Zend/zend_ini_scanner.l"
#line 554 "Zend/zend_ini_scanner.l"
{ /* Get constant option value */
RETURN_TOKEN(TC_CONSTANT, yytext, yyleng);
}
#line 2227 "Zend/zend_ini_scanner.c"
#line 2226 "Zend/zend_ini_scanner.c"
yy163:
YYDEBUG(163, *YYCURSOR);
yyaccept = 2;
@@ -2557,12 +2556,12 @@ yy171:
++YYCURSOR;
YYDEBUG(172, *YYCURSOR);
yyleng = YYCURSOR - SCNG(yy_text);
#line 450 "Zend/zend_ini_scanner.l"
#line 449 "Zend/zend_ini_scanner.l"
{ /* Variable start */
yy_push_state(ST_VARNAME);
return TC_DOLLAR_CURLY;
}
#line 2566 "Zend/zend_ini_scanner.c"
#line 2565 "Zend/zend_ini_scanner.c"
yy173:
YYDEBUG(173, *YYCURSOR);
++YYCURSOR;
@@ -2628,13 +2627,13 @@ yy177:
yy178:
YYDEBUG(178, *YYCURSOR);
yyleng = YYCURSOR - SCNG(yy_text);
#line 645 "Zend/zend_ini_scanner.l"
#line 644 "Zend/zend_ini_scanner.l"
{ /* Comment */
BEGIN(INITIAL);
SCNG(lineno)++;
return END_OF_LINE;
}
#line 2638 "Zend/zend_ini_scanner.c"
#line 2637 "Zend/zend_ini_scanner.c"
yy179:
YYDEBUG(179, *YYCURSOR);
yych = *++YYCURSOR;
@@ -2745,11 +2744,11 @@ yy181:
yy182:
YYDEBUG(182, *YYCURSOR);
yyleng = YYCURSOR - SCNG(yy_text);
#line 474 "Zend/zend_ini_scanner.l"
#line 473 "Zend/zend_ini_scanner.l"
{ /* FALSE value (when used outside option value/offset this causes parse error!)*/
RETURN_TOKEN(BOOL_FALSE, "", 0);
}
#line 2753 "Zend/zend_ini_scanner.c"
#line 2752 "Zend/zend_ini_scanner.c"
yy183:
YYDEBUG(183, *YYCURSOR);
yyaccept = 2;
@@ -2896,11 +2895,11 @@ yy185:
yy186:
YYDEBUG(186, *YYCURSOR);
yyleng = YYCURSOR - SCNG(yy_text);
#line 470 "Zend/zend_ini_scanner.l"
#line 469 "Zend/zend_ini_scanner.l"
{ /* TRUE value (when used outside option value/offset this causes parse error!) */
RETURN_TOKEN(BOOL_TRUE, "1", 1);
}
#line 2904 "Zend/zend_ini_scanner.c"
#line 2903 "Zend/zend_ini_scanner.c"
yy187:
YYDEBUG(187, *YYCURSOR);
yyaccept = 2;
@@ -3020,7 +3019,7 @@ yy191:
++YYCURSOR;
YYDEBUG(192, *YYCURSOR);
yyleng = YYCURSOR - SCNG(yy_text);
#line 417 "Zend/zend_ini_scanner.l"
#line 416 "Zend/zend_ini_scanner.l"
{ /* Raw string */
/* Eat leading and trailing single quotes */
if (yytext[0] == '\'' && yytext[yyleng - 1] == '\'') {
@@ -3029,7 +3028,7 @@ yy191:
}
RETURN_TOKEN(TC_RAW, yytext, yyleng);
}
#line 3033 "Zend/zend_ini_scanner.c"
#line 3032 "Zend/zend_ini_scanner.c"
yy193:
YYDEBUG(193, *YYCURSOR);
yyaccept = 2;
@@ -3344,11 +3343,11 @@ yy202:
yy203:
YYDEBUG(203, *YYCURSOR);
yyleng = YYCURSOR - SCNG(yy_text);
#line 478 "Zend/zend_ini_scanner.l"
#line 477 "Zend/zend_ini_scanner.l"
{
RETURN_TOKEN(NULL_NULL, "", 0);
}
#line 3352 "Zend/zend_ini_scanner.c"
#line 3351 "Zend/zend_ini_scanner.c"
yy204:
YYDEBUG(204, *YYCURSOR);
++YYCURSOR;
@@ -3415,21 +3414,21 @@ yy208:
}
YYDEBUG(210, *YYCURSOR);
yyleng = YYCURSOR - SCNG(yy_text);
#line 545 "Zend/zend_ini_scanner.l"
#line 544 "Zend/zend_ini_scanner.l"
{ /* Raw value, only used when SCNG(scanner_mode) == ZEND_INI_SCANNER_RAW. */
RETURN_TOKEN(TC_RAW, yytext, yyleng);
}
#line 3423 "Zend/zend_ini_scanner.c"
#line 3422 "Zend/zend_ini_scanner.c"
yy211:
YYDEBUG(211, *YYCURSOR);
++YYCURSOR;
YYDEBUG(212, *YYCURSOR);
yyleng = YYCURSOR - SCNG(yy_text);
#line 656 "Zend/zend_ini_scanner.l"
#line 655 "Zend/zend_ini_scanner.l"
{
return 0;
}
#line 3433 "Zend/zend_ini_scanner.c"
#line 3432 "Zend/zend_ini_scanner.c"
yy213:
YYDEBUG(213, *YYCURSOR);
++YYCURSOR;
@@ -3445,13 +3444,13 @@ yy213:
yy215:
YYDEBUG(215, *YYCURSOR);
yyleng = YYCURSOR - SCNG(yy_text);
#line 426 "Zend/zend_ini_scanner.l"
#line 425 "Zend/zend_ini_scanner.l"
{ /* End of section */
BEGIN(INITIAL);
SCNG(lineno)++;
return ']';
}
#line 3455 "Zend/zend_ini_scanner.c"
#line 3454 "Zend/zend_ini_scanner.c"
yy216:
YYDEBUG(216, *YYCURSOR);
++YYCURSOR;
@@ -3509,7 +3508,7 @@ yyc_ST_DOUBLE_QUOTES:
yy221:
YYDEBUG(221, *YYCURSOR);
yyleng = YYCURSOR - SCNG(yy_text);
#line 595 "Zend/zend_ini_scanner.l"
#line 594 "Zend/zend_ini_scanner.l"
{ /* Escape double quoted string contents */
if (YYCURSOR > YYLIMIT) {
return 0;
@@ -3545,7 +3544,7 @@ yy221:
zend_ini_escape_string(ini_lval, yytext, yyleng, '"');
return TC_QUOTED_STRING;
}
#line 3549 "Zend/zend_ini_scanner.c"
#line 3548 "Zend/zend_ini_scanner.c"
yy222:
YYDEBUG(222, *YYCURSOR);
++YYCURSOR;
@@ -3557,12 +3556,12 @@ yy222:
}
YYDEBUG(224, *YYCURSOR);
yyleng = YYCURSOR - SCNG(yy_text);
#line 590 "Zend/zend_ini_scanner.l"
#line 589 "Zend/zend_ini_scanner.l"
{ /* Double quoted '"' string ends */
yy_pop_state();
return '"';
}
#line 3566 "Zend/zend_ini_scanner.c"
#line 3565 "Zend/zend_ini_scanner.c"
yy225:
YYDEBUG(225, *YYCURSOR);
yych = *++YYCURSOR;
@@ -3571,12 +3570,12 @@ yy225:
++YYCURSOR;
YYDEBUG(227, *YYCURSOR);
yyleng = YYCURSOR - SCNG(yy_text);
#line 450 "Zend/zend_ini_scanner.l"
#line 449 "Zend/zend_ini_scanner.l"
{ /* Variable start */
yy_push_state(ST_VARNAME);
return TC_DOLLAR_CURLY;
}
#line 3580 "Zend/zend_ini_scanner.c"
#line 3579 "Zend/zend_ini_scanner.c"
}
/* *********************************** */
yyc_ST_VARNAME:
@@ -3634,7 +3633,7 @@ yy230:
}
YYDEBUG(232, *YYCURSOR);
yyleng = YYCURSOR - SCNG(yy_text);
#line 455 "Zend/zend_ini_scanner.l"
#line 454 "Zend/zend_ini_scanner.l"
{ /* Variable name */
/* Eat leading whitespace */
EAT_LEADING_WHITESPACE();
@@ -3644,28 +3643,28 @@ yy230:
RETURN_TOKEN(TC_VARNAME, yytext, yyleng);
}
#line 3648 "Zend/zend_ini_scanner.c"
#line 3647 "Zend/zend_ini_scanner.c"
yy233:
YYDEBUG(233, *YYCURSOR);
++YYCURSOR;
YYDEBUG(234, *YYCURSOR);
yyleng = YYCURSOR - SCNG(yy_text);
#line 656 "Zend/zend_ini_scanner.l"
#line 655 "Zend/zend_ini_scanner.l"
{
return 0;
}
#line 3658 "Zend/zend_ini_scanner.c"
#line 3657 "Zend/zend_ini_scanner.c"
yy235:
YYDEBUG(235, *YYCURSOR);
++YYCURSOR;
YYDEBUG(236, *YYCURSOR);
yyleng = YYCURSOR - SCNG(yy_text);
#line 465 "Zend/zend_ini_scanner.l"
#line 464 "Zend/zend_ini_scanner.l"
{ /* Variable end */
yy_pop_state();
return '}';
}
#line 3669 "Zend/zend_ini_scanner.c"
#line 3668 "Zend/zend_ini_scanner.c"
}
/* *********************************** */
yyc_ST_RAW:
@@ -3729,19 +3728,19 @@ yyc_ST_RAW:
++YYCURSOR;
YYDEBUG(240, *YYCURSOR);
yyleng = YYCURSOR - SCNG(yy_text);
#line 651 "Zend/zend_ini_scanner.l"
#line 650 "Zend/zend_ini_scanner.l"
{ /* End of option value (if EOF is reached before EOL */
BEGIN(INITIAL);
return END_OF_LINE;
}
#line 3738 "Zend/zend_ini_scanner.c"
#line 3737 "Zend/zend_ini_scanner.c"
yy241:
YYDEBUG(241, *YYCURSOR);
++YYCURSOR;
yy242:
YYDEBUG(242, *YYCURSOR);
yyleng = YYCURSOR - SCNG(yy_text);
#line 501 "Zend/zend_ini_scanner.l"
#line 500 "Zend/zend_ini_scanner.l"
{ /* Raw value, only used when SCNG(scanner_mode) == ZEND_INI_SCANNER_RAW. */
unsigned char *sc = NULL;
EAT_LEADING_WHITESPACE();
@@ -3785,7 +3784,7 @@ end_raw_value_chars:
RETURN_TOKEN(TC_RAW, yytext, yyleng);
}
#line 3789 "Zend/zend_ini_scanner.c"
#line 3788 "Zend/zend_ini_scanner.c"
yy243:
YYDEBUG(243, *YYCURSOR);
yych = *++YYCURSOR;
@@ -3809,13 +3808,13 @@ yy244:
yy245:
YYDEBUG(245, *YYCURSOR);
yyleng = YYCURSOR - SCNG(yy_text);
#line 549 "Zend/zend_ini_scanner.l"
#line 548 "Zend/zend_ini_scanner.l"
{ /* End of option value */
BEGIN(INITIAL);
SCNG(lineno)++;
return END_OF_LINE;
}
#line 3819 "Zend/zend_ini_scanner.c"
#line 3818 "Zend/zend_ini_scanner.c"
yy246:
YYDEBUG(246, *YYCURSOR);
yych = *++YYCURSOR;
@@ -3852,25 +3851,25 @@ yy250:
yy251:
YYDEBUG(251, *YYCURSOR);
yyleng = YYCURSOR - SCNG(yy_text);
#line 635 "Zend/zend_ini_scanner.l"
#line 634 "Zend/zend_ini_scanner.l"
{
/* eat whitespace */
goto restart;
}
#line 3861 "Zend/zend_ini_scanner.c"
#line 3860 "Zend/zend_ini_scanner.c"
yy252:
YYDEBUG(252, *YYCURSOR);
++YYCURSOR;
yy253:
YYDEBUG(253, *YYCURSOR);
yyleng = YYCURSOR - SCNG(yy_text);
#line 645 "Zend/zend_ini_scanner.l"
#line 644 "Zend/zend_ini_scanner.l"
{ /* Comment */
BEGIN(INITIAL);
SCNG(lineno)++;
return END_OF_LINE;
}
#line 3874 "Zend/zend_ini_scanner.c"
#line 3873 "Zend/zend_ini_scanner.c"
yy254:
YYDEBUG(254, *YYCURSOR);
yych = *++YYCURSOR;
@@ -3878,6 +3877,6 @@ yy254:
goto yy253;
}
}
#line 660 "Zend/zend_ini_scanner.l"
#line 659 "Zend/zend_ini_scanner.l"
}
+7 -8
View File
@@ -140,14 +140,13 @@ ZEND_API zend_ini_scanner_globals ini_scanner_globals;
ZVAL_NEW_STR(retval, zend_string_init(str, len, ZEND_SYSTEM_INI))
#define RETURN_TOKEN(type, str, len) { \
if (SCNG(scanner_mode) == ZEND_INI_SCANNER_TYPED && \
(YYSTATE == STATE(ST_VALUE) || YYSTATE == STATE(ST_RAW))) {\
zend_ini_copy_typed_value(ini_lval, type, str, len); \
} else { \
zend_ini_copy_value(ini_lval, str, len); \
} \
return type; \
#define RETURN_TOKEN(type, str, len) { \
if (SCNG(scanner_mode) == ZEND_INI_SCANNER_TYPED) { \
zend_ini_copy_typed_value(ini_lval, type, str, len); \
} else { \
zend_ini_copy_value(ini_lval, str, len); \
} \
return type; \
}
static inline int convert_to_number(zval *retval, const char *str, const int str_len)
+1 -1
View File
@@ -1312,7 +1312,7 @@ static YYSIZE_T zend_yytnamerr(char *yyres, const char *yystr)
if (LANG_SCNG(yy_text)[0] == 0 &&
LANG_SCNG(yy_leng) == 1 &&
strcmp(yystr, "\"end of file\"") == 0) {
memcmp(yystr, "\"end of file\"", sizeof("\"end of file\"") - 1) == 0) {
if (yyres) {
yystpcpy(yyres, "end of file");
}
File diff suppressed because it is too large. Load diff
+6 -28
View File
@@ -115,7 +115,6 @@ do { \
#define GET_DOUBLE_QUOTES_SCANNED_LENGTH() SCNG(scanned_string_len)
#define IS_LABEL_START(c) (((c) >= 'a' && (c) <= 'z') || ((c) >= 'A' && (c) <= 'Z') || (c) == '_' || (c) >= 0x80)
#define IS_LABEL_SUCCESSOR(c) (((c) >= 'a' && (c) <= 'z') || ((c) >= 'A' && (c) <= 'Z') || ((c) >= '0' && (c) <= '9') || (c) == '_' || (c) >= 0x80)
#define ZEND_IS_OCT(c) ((c)>='0' && (c)<='7')
#define ZEND_IS_HEX(c) (((c)>='0' && (c)<='9') || ((c)>='a' && (c)<='f') || ((c)>='A' && (c)<='F'))
@@ -1782,8 +1781,7 @@ NEWLINE ("\r"|"\n"|"\r\n")
char *end;
if (yyleng < MAX_LENGTH_OF_LONG - 1) { /* Won't overflow */
errno = 0;
/* base must be passed explicitly for correct parse error on Windows */
ZVAL_LONG(zendlval, ZEND_STRTOL(yytext, &end, yytext[0] == '0' ? 8 : 10));
ZVAL_LONG(zendlval, ZEND_STRTOL(yytext, &end, 0));
/* This isn't an assert, we need to ensure 019 isn't valid octal
* Because the lexing itself doesn't do that for us
*/
@@ -2098,7 +2096,7 @@ inline_char_handler:
if (YYCURSOR < YYLIMIT) {
YYCURSOR++;
} else if (!SCNG(heredoc_scan_ahead)) {
} else {
zend_error(E_COMPILE_WARNING, "Unterminated comment starting line %d", CG(zend_lineno));
}
@@ -2320,12 +2318,9 @@ skip_escape_conversion:
/* Check for ending label on the next line */
if (heredoc_label->length < YYLIMIT - YYCURSOR && !memcmp(YYCURSOR, s, heredoc_label->length)) {
if (!IS_LABEL_SUCCESSOR(YYCURSOR[heredoc_label->length])) {
if (!IS_LABEL_START(YYCURSOR[heredoc_label->length])) {
if (spacing == (HEREDOC_USING_SPACES | HEREDOC_USING_TABS)) {
zend_throw_exception(zend_ce_parse_error, "Invalid indentation - tabs and spaces cannot be mixed", 0);
if (PARSER_MODE()) {
RETURN_TOKEN(T_ERROR);
}
}
YYCURSOR = saved_cursor;
@@ -2340,10 +2335,8 @@ skip_escape_conversion:
if (is_heredoc && !SCNG(heredoc_scan_ahead)) {
zend_lex_state current_state;
zend_string *saved_doc_comment = CG(doc_comment);
int heredoc_nesting_level = 1;
int first_token = 0;
int error = 0;
zend_save_lexical_state(&current_state);
@@ -2351,7 +2344,6 @@ skip_escape_conversion:
SCNG(heredoc_indentation) = 0;
SCNG(heredoc_indentation_uses_spaces) = 0;
LANG_SCNG(on_event) = NULL;
CG(doc_comment) = NULL;
zend_ptr_stack_reverse_apply(&current_state.heredoc_label_stack, copy_heredoc_label_stack);
@@ -2392,7 +2384,6 @@ skip_escape_conversion:
|| first_token == T_CURLY_OPEN
) && SCNG(heredoc_indentation)) {
zend_throw_exception_ex(zend_ce_parse_error, 0, "Invalid body indentation level (expecting an indentation level of at least %d)", SCNG(heredoc_indentation));
error = 1;
}
heredoc_label->indentation = SCNG(heredoc_indentation);
@@ -2401,11 +2392,6 @@ skip_escape_conversion:
zend_restore_lexical_state(&current_state);
SCNG(heredoc_scan_ahead) = 0;
CG(increment_lineno) = 0;
CG(doc_comment) = saved_doc_comment;
if (PARSER_MODE() && error) {
RETURN_TOKEN(T_ERROR);
}
}
RETURN_TOKEN(T_START_HEREDOC);
@@ -2589,15 +2575,12 @@ double_quotes_scan_done:
/* Check for ending label on the next line */
if (IS_LABEL_START(*YYCURSOR) && heredoc_label->length < YYLIMIT - YYCURSOR && !memcmp(YYCURSOR, heredoc_label->label, heredoc_label->length)) {
if (IS_LABEL_SUCCESSOR(YYCURSOR[heredoc_label->length])) {
if (IS_LABEL_START(YYCURSOR[heredoc_label->length])) {
continue;
}
if (spacing == (HEREDOC_USING_SPACES | HEREDOC_USING_TABS)) {
zend_throw_exception(zend_ce_parse_error, "Invalid indentation - tabs and spaces cannot be mixed", 0);
if (PARSER_MODE()) {
RETURN_TOKEN(T_ERROR);
}
}
/* newline before label will be subtracted from returned text, but
@@ -2713,15 +2696,12 @@ heredoc_scan_done:
/* Check for ending label on the next line */
if (IS_LABEL_START(*YYCURSOR) && heredoc_label->length < YYLIMIT - YYCURSOR && !memcmp(YYCURSOR, heredoc_label->label, heredoc_label->length)) {
if (IS_LABEL_SUCCESSOR(YYCURSOR[heredoc_label->length])) {
if (IS_LABEL_START(YYCURSOR[heredoc_label->length])) {
continue;
}
if (spacing == (HEREDOC_USING_SPACES | HEREDOC_USING_TABS)) {
zend_throw_exception(zend_ce_parse_error, "Invalid indentation - tabs and spaces cannot be mixed", 0);
if (PARSER_MODE()) {
RETURN_TOKEN(T_ERROR);
}
}
/* newline before label will be subtracted from returned text, but
@@ -2770,9 +2750,7 @@ nowdoc_scan_done:
RETURN_TOKEN(END);
}
if (!SCNG(heredoc_scan_ahead)) {
zend_error(E_COMPILE_WARNING, "Unexpected character in input: '%c' (ASCII=%d) state=%d", yytext[0], yytext[0], YYSTATE);
}
zend_error(E_COMPILE_WARNING,"Unexpected character in input: '%c' (ASCII=%d) state=%d", yytext[0], yytext[0], YYSTATE);
goto restart;
}
+3 -8
View File
@@ -124,11 +124,6 @@ ZEND_API HashTable *zend_std_get_gc(zval *object, zval **table, int *n) /* {{{ *
if (zobj->properties) {
*table = NULL;
*n = 0;
if (UNEXPECTED(GC_REFCOUNT(zobj->properties) > 1)
&& EXPECTED(!(GC_FLAGS(zobj->properties) & IS_ARRAY_IMMUTABLE))) {
GC_DELREF(zobj->properties);
zobj->properties = zend_array_dup(zobj->properties);
}
return zobj->properties;
} else {
*table = zobj->properties_table;
@@ -1379,14 +1374,14 @@ ZEND_API zend_function *zend_std_get_static_method(zend_class_entry *ce, zend_st
}
/* }}} */
ZEND_API void zend_class_init_statics(zend_class_entry *class_type) /* {{{ */
static void zend_intenal_class_init_statics(zend_class_entry *class_type) /* {{{ */
{
int i;
zval *p;
if (!CE_STATIC_MEMBERS(class_type) && class_type->default_static_members_count) {
if (class_type->parent) {
zend_class_init_statics(class_type->parent);
zend_intenal_class_init_statics(class_type->parent);
}
#if ZTS
@@ -1436,7 +1431,7 @@ ZEND_API zval *zend_std_get_static_property(zend_class_entry *ce, zend_string *p
/* check if static properties were destoyed */
if (UNEXPECTED(CE_STATIC_MEMBERS(ce) == NULL)) {
if (ce->type == ZEND_INTERNAL_CLASS) {
zend_class_init_statics(ce);
zend_intenal_class_init_statics(ce);
} else {
undeclared_property:
if (!silent) {
-1
View File
@@ -175,7 +175,6 @@ extern const ZEND_API zend_object_handlers std_object_handlers;
#define ZEND_PROPERTY_NOT_EMPTY ZEND_ISEMPTY /* Property is not empty */
#define ZEND_PROPERTY_EXISTS 0x2 /* Property exists */
ZEND_API void zend_class_init_statics(zend_class_entry *ce);
ZEND_API zend_function *zend_std_get_static_method(zend_class_entry *ce, zend_string *function_name_strval, const zval *key);
ZEND_API zval *zend_std_get_static_property(zend_class_entry *ce, zend_string *property_name, zend_bool silent);
ZEND_API ZEND_COLD zend_bool zend_std_unset_static_property(zend_class_entry *ce, zend_string *property_name);
+1 -2
View File
@@ -43,8 +43,7 @@ ZEND_API void zend_object_std_dtor(zend_object *object)
if (object->properties) {
if (EXPECTED(!(GC_FLAGS(object->properties) & IS_ARRAY_IMMUTABLE))) {
if (EXPECTED(GC_DELREF(object->properties) == 0)
&& EXPECTED(GC_TYPE(object->properties) != IS_NULL)) {
if (EXPECTED(GC_DELREF(object->properties) == 0)) {
zend_array_destroy(object->properties);
}
}
+6 -12
View File
@@ -41,7 +41,6 @@ ZEND_API void ZEND_FASTCALL zend_objects_store_destroy(zend_objects_store *objec
ZEND_API void ZEND_FASTCALL zend_objects_store_call_destructors(zend_objects_store *objects)
{
EG(flags) |= EG_FLAGS_OBJECT_STORE_NO_REUSE;
if (objects->top > 1) {
uint32_t i;
for (i = 1; i < objects->top; i++) {
@@ -132,10 +131,10 @@ ZEND_API void ZEND_FASTCALL zend_objects_store_put(zend_object *object)
{
int handle;
/* When in shutdown sequence - do not reuse previously freed handles, to make sure
/* When in shutdown sequesnce - do not reuse previously freed handles, to make sure
* the dtors for newly created objects are called in zend_objects_store_call_destructors() loop
*/
if (EG(objects_store).free_list_head != -1 && EXPECTED(!(EG(flags) & EG_FLAGS_OBJECT_STORE_NO_REUSE))) {
if (!(EG(flags) & EG_FLAGS_IN_SHUTDOWN) && EG(objects_store).free_list_head != -1) {
handle = EG(objects_store).free_list_head;
EG(objects_store).free_list_head = GET_OBJ_BUCKET_NUMBER(EG(objects_store).object_buckets[handle]);
} else {
@@ -153,17 +152,14 @@ ZEND_API void ZEND_FASTCALL zend_objects_store_put(zend_object *object)
ZEND_API void ZEND_FASTCALL zend_objects_store_del(zend_object *object) /* {{{ */
{
ZEND_ASSERT(GC_REFCOUNT(object) == 0);
/* GC might have released this object already. */
if (UNEXPECTED(GC_TYPE(object) == IS_NULL)) {
return;
}
/* Make sure we hold a reference count during the destructor call
otherwise, when the destructor ends the storage might be freed
when the refcount reaches 0 a second time
*/
ZEND_ASSERT(EG(objects_store).object_buckets != NULL);
ZEND_ASSERT(IS_OBJ_VALID(EG(objects_store).object_buckets[object->handle]));
ZEND_ASSERT(GC_REFCOUNT(object) == 0);
if (!(OBJ_FLAGS(object) & IS_OBJ_DESTRUCTOR_CALLED)) {
GC_ADD_FLAGS(object, IS_OBJ_DESTRUCTOR_CALLED);
@@ -180,8 +176,6 @@ ZEND_API void ZEND_FASTCALL zend_objects_store_del(zend_object *object) /* {{{ *
uint32_t handle = object->handle;
void *ptr;
ZEND_ASSERT(EG(objects_store).object_buckets != NULL);
ZEND_ASSERT(IS_OBJ_VALID(EG(objects_store).object_buckets[object->handle]));
EG(objects_store).object_buckets[handle] = SET_OBJ_INVALID(object);
if (!(OBJ_FLAGS(object) & IS_OBJ_FREE_CALLED)) {
GC_ADD_FLAGS(object, IS_OBJ_FREE_CALLED);
Loaded 100 of 1113 files, more files were not shown because too many files have changed in this diff. Show more