Merge branch 'master' into zppFailOnOverflow

This commit is contained in:
Andrea Faulds 2014-11-29 01:45:54 +00:00
commit 01554bf3e4
412 changed files with 10007 additions and 4913 deletions

View file

@ -42,7 +42,7 @@ Exceptions:
4. When writing functions that deal with strings, be sure to remember
that PHP holds the length property of each string, and that it
shouldn't be calculated with strlen(). Write your functions in a such
shouldn't be calculated with strlen(). Write your functions in such
a way so that they'll take advantage of the length property, both
for efficiency and in order for them to be binary-safe.
Functions that change strings and obtain their new lengths while

View file

@ -155,7 +155,7 @@ Table of Contents
a list of all available options along with short explanations running
./configure --help. Our manual documents the different options
separately. You will find the core options in the appendix, while the
different extension specific options are descibed on the reference
different extension specific options are described on the reference
pages.
When PHP is configured, you are ready to build the module and/or

54
NEWS
View file

@ -2,9 +2,6 @@ PHP NEWS
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
?? ??? 20??, PHP 7.0.0
-Fileinfo:
. Fixed bug #66242 (libmagic: don't assume char is signed). (ArdB)
- CLI server:
. Refactor MIME type handling to use a hash table instead of linear search.
(Adam)
@ -20,17 +17,47 @@ PHP NEWS
. Implemented FR #38409 (parse_ini_file() looses the type of booleans). (Tjerk)
. Fixed #67959 (Segfault when calling phpversion('spl')). (Florian)
. Implemented the RFC `Catchable "Call to a member function bar() on a
non-object"` (Timm)
- Reflection
. Fixed inheritance chain of Reflector interface (Tjerk)
non-object"`. (Timm)
. Added options parameter for unserialize allowing to specify acceptable
classes (https://wiki.php.net/rfc/secure_unserialize). (Stas)
. Fixed bug #68185 ("Inconsistent insteadof definition."- incorrectly triggered). (Julien)
. Fixed bug #65419 (Inside trait, self::class != __CLASS__). (Julien)
- DBA:
. Fixed bug #62490 (dba_delete returns true on missing item (inifile)). (Mike)
- DOM:
. Made DOMNode::textContent writeable. (Tjerk)
- GD:
. Made fontFetch's path parser thread-safe. (Sara)
- Fileinfo:
. Fixed bug #66242 (libmagic: don't assume char is signed). (ArdB)
- Filter:
. New FILTER_VALIDATE_DOMAIN and better RFC conformance for FILTER_VALIDATE_URL. (Kevin Dunglas)
- FPM:
. Fixed bug #65933 (Cannot specify config lines longer than 1024 bytes). (Chris Wright)
- LiteSpeed:
. Updated LiteSpeed SAPI code from V5.5 to V6.6. (George Wang)
- Reflection
. Fixed inheritance chain of Reflector interface (Tjerk)
- Session:
. Fixed bug #67694 (Regression in session_regenerate_id()). (Tjerk)
- SOAP:
. Fixed bug #68361 (Segmentation fault on SoapClient::__getTypes).
(Laruence)
- SPL:
. Implemented #67886 (SplPriorityQueue/SplHeap doesn't expose extractFlags
nor curruption state). (Julien)
- Standard:
. Removed call_user_method() and call_user_method_array() functions. (Kalle)
. Fix user session handlers (See rfc:session.user.return-value). (Sara)
@ -40,17 +67,4 @@ PHP NEWS
- XSL:
. Fixed bug #64776 (The XSLT extension is not thread safe). (Mike)
- GD:
. Made fontFetch's path parser thread-safe. (Sara)
- Session:
. Fixed bug #67694 (Regression in session_regenerate_id()). (Tjerk)
- SPL:
. Implemented #67886 (SplPriorityQueue/SplHeap doesn't expose extractFlags
nor curruption state). (Julien)
- DOM:
. Made DOMNode::textContent writeable. (Tjerk)
<<< NOTE: Insert NEWS from last stable release here prior to actual release! >>>

View file

@ -123,7 +123,7 @@ MYMAIL=qa-test@domain.com
TMPDIR=/var/tmp
TODAY=`date +"%Y%m%d"`
# Make sure compilation enviroment is correct
# Make sure compilation environment is correct
CONFIGURE_OPTS='--disable-all --enable-cli --with-pcre'
export MAKE=gmake
export CC=gcc

View file

@ -8,7 +8,7 @@ the original run-tests.php script. server-tests is *not* used by
'make test'. server-tests was developed to provide support for
testing PHP under it's primary environment, HTTP, and can run the
PHP tests under any of the SAPI modules that are direct executables,
or are accessable via HTTP.
or are accessible via HTTP.
[New features]
----------------
@ -95,7 +95,7 @@ include:
$filename full native path to file, will become PATH_TRANSLATED
$filepath =dirname($filename)
$scriptname this is what will become SCRIPT_NAME unless you override it
$docroot the equivelant of DOCUMENT_ROOT under Apache
$docroot the equivalent of DOCUMENT_ROOT under Apache
$cwd the directory that the test is being initiated from
$this->conf all server-tests configuration vars
$this->env all environment variables that will get passed to the test
@ -105,7 +105,7 @@ include:
This section is also eval'd, and is similar in nature to --ENV--. However,
this section is used to build the url used in an HTTP request. Valid values
to set in this section would include:
SCRIPT_NAME The inital part of the request url
SCRIPT_NAME The initial part of the request url
PATH_INFO The pathinfo part of a request url
FRAGMENT The fragment section of a url (after #)
QUERY_STRING The query part of a url (after ?)

View file

@ -106,16 +106,18 @@ TSRM_API void tsrm_win32_shutdown(void)
char * tsrm_win32_get_path_sid_key(const char *pathname TSRMLS_DC)
{
PSID pSid = TWG(impersonation_token_sid);
DWORD sid_len = pSid ? GetLengthSid(pSid) : 0;
TCHAR *ptcSid = NULL;
char *bucket_key = NULL;
size_t ptc_sid_len, pathname_len;
pathname_len = strlen(pathname);
if (!pSid) {
bucket_key = (char *)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, strlen(pathname) + 1);
bucket_key = (char *)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, pathname_len + 1);
if (!bucket_key) {
return NULL;
}
memcpy(bucket_key, pathname, strlen(pathname));
memcpy(bucket_key, pathname, pathname_len);
return bucket_key;
}
@ -123,14 +125,16 @@ char * tsrm_win32_get_path_sid_key(const char *pathname TSRMLS_DC)
return NULL;
}
bucket_key = (char *)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, strlen(pathname) + strlen(ptcSid) + 1);
ptc_sid_len = strlen(ptcSid);
bucket_key = (char *)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, pathname_len + ptc_sid_len + 1);
if (!bucket_key) {
LocalFree(ptcSid);
return NULL;
}
memcpy(bucket_key, ptcSid, strlen(ptcSid));
memcpy(bucket_key + strlen(ptcSid), pathname, strlen(pathname) + 1);
memcpy(bucket_key, ptcSid, ptc_sid_len);
memcpy(bucket_key + ptc_sid_len, pathname, pathname_len + 1);
LocalFree(ptcSid);
return bucket_key;
@ -139,11 +143,8 @@ char * tsrm_win32_get_path_sid_key(const char *pathname TSRMLS_DC)
PSID tsrm_win32_get_token_sid(HANDLE hToken)
{
BOOL bSuccess = FALSE;
DWORD dwLength = 0;
PTOKEN_USER pTokenUser = NULL;
PSID sid;
PSID *ppsid = &sid;
DWORD sid_len;
PSID pResultSid = NULL;
@ -204,7 +205,6 @@ TSRM_API int tsrm_win32_access(const char *pathname, int mode TSRMLS_DC)
BYTE * psec_desc = NULL;
BOOL fAccess = FALSE;
BOOL bucket_key_alloc = FALSE;
realpath_cache_bucket * bucket = NULL;
char * real_path = NULL;
@ -242,7 +242,6 @@ TSRM_API int tsrm_win32_access(const char *pathname, int mode TSRMLS_DC)
was impersonating already, this function uses that impersonation context.
*/
if(!OpenThreadToken(GetCurrentThread(), TOKEN_ALL_ACCESS, TRUE, &thread_token)) {
DWORD err = GetLastError();
if (GetLastError() == ERROR_NO_TOKEN) {
if (!OpenProcessToken(GetCurrentProcess(), TOKEN_ALL_ACCESS, &thread_token)) {
TWG(impersonation_token) = NULL;
@ -722,4 +721,52 @@ TSRM_API char *realpath(char *orig_path, char *buffer)
return buffer;
}
#if HAVE_UTIME
static zend_always_inline void UnixTimeToFileTime(time_t t, LPFILETIME pft) /* {{{ */
{
// Note that LONGLONG is a 64-bit value
LONGLONG ll;
ll = Int32x32To64(t, 10000000) + 116444736000000000;
pft->dwLowDateTime = (DWORD)ll;
pft->dwHighDateTime = ll >> 32;
}
/* }}} */
TSRM_API int win32_utime(const char *filename, struct utimbuf *buf) /* {{{ */
{
FILETIME mtime, atime;
HANDLE hFile;
hFile = CreateFile(filename, GENERIC_WRITE, FILE_SHARE_WRITE|FILE_SHARE_READ, NULL,
OPEN_ALWAYS, FILE_FLAG_BACKUP_SEMANTICS, NULL);
/* OPEN_ALWAYS mode sets the last error to ERROR_ALREADY_EXISTS but
the CreateFile operation succeeds */
if (GetLastError() == ERROR_ALREADY_EXISTS) {
SetLastError(0);
}
if ( hFile == INVALID_HANDLE_VALUE ) {
return -1;
}
if (!buf) {
SYSTEMTIME st;
GetSystemTime(&st);
SystemTimeToFileTime(&st, &mtime);
atime = mtime;
} else {
UnixTimeToFileTime(buf->modtime, &mtime);
UnixTimeToFileTime(buf->actime, &atime);
}
if (!SetFileTime(hFile, NULL, &atime, &mtime)) {
CloseHandle(hFile);
return -1;
}
CloseHandle(hFile);
return 1;
}
/* }}} */
#endif
#endif

View file

@ -23,6 +23,9 @@
#include "TSRM.h"
#include <windows.h>
#if HAVE_UTIME
# include <sys/utime.h>
#endif
struct ipc_perm {
int key;

View file

@ -63,6 +63,7 @@ PHP X.Y UPGRADE NOTES
- FPM
. Fixed bug #65933 (Cannot specify config lines longer than 1024 bytes).
. Listen = port now listen on all addresses (IPv6 and IPv4-mapped).
========================================
4. Deprecated Functionality
@ -76,6 +77,11 @@ PHP X.Y UPGRADE NOTES
- parse_ini_file():
- parse_ini_string():
Added scanner mode INI_SCANNER_TYPED to yield typed .ini values.
- unserialize():
Added second parameter for unserialize function
(RFC: https://wiki.php.net/rfc/secure_unserialize) allowing to specify
acceptable classes:
unserialize($foo, ["allowed_classes" => ["MyClass", "MyClass2"]);
========================================
@ -126,7 +132,7 @@ PHP X.Y UPGRADE NOTES
========================================
- Core
. Instead of being undefined and platform-dependant, NaN and Infinity will
. Instead of being undefined and platform-dependent, NaN and Infinity will
always be zero when casted to integer.
. Calling a method on a non-object no longer raises a fatal error; see
also: https://wiki.php.net/rfc/catchable-call-to-member-of-non-object

View file

@ -9,6 +9,9 @@ PHP 7.0 INTERNALS UPGRADE NOTES
h. HashTable API
i. New portable macros for large file support
j. New portable macros for integers
k. get_class_entry object handler info
l. get_class_name object handler info
m. Other portable macros info
2. Build system changes
a. Unix build system changes
@ -110,8 +113,34 @@ PHP 7.0 INTERNALS UPGRADE NOTES
The handler is now obligatory, no longer accepts a `parent` argument and
must return a non-NULL zend_string*, which will be released by the caller.
m. Other portable macros info
ZEND_SECURE_ZERO - zeroes chunk of memory
ZEND_VALID_SOCKET - validates a php_socket_t variable
ZEND_FASTCALL is defined to use __vectorcall convention on VS2013 and above
ZEND_NORETURN is defined as __declspec(noreturn) on VS
========================
2. Build system changes
========================
a. Unix build system changes
b. Windows build system changes
- Besides Visual Studio, building with Clang or Intel Composer is now
possible. To enable an alternative toolset, add the option
--with-toolset=[vs,clang,icc] to the configure line. The default
toolset is vs. Still clang or icc need the correct environment
which involves many tools from the vs toolset.
The toolset option is supported by phpize as well.
AWARENESS The only recommended and supported toolset to produce production
ready binaries is Visual Studio. Still other compilers can be used now for
testing and analyzing purposes.
- configure.js now produces response files which are passed to the linker
and library manager. This solves the issues with the long command lines
which can exceed the OS limit.

View file

@ -1103,7 +1103,7 @@ Changes in the Zend Engine 1.0
Use ob_start() to begin output buffering, ob_end_flush() to end
buffering and send out the buffered contents, ob_end_clean() to
end buffering without sending the buffered contents, and
ob_get_contents() to retreive the current contents of the output
ob_get_contents() to retrieve the current contents of the output
buffer. Header information (header(), content type, cookies) are
not buffered. By turning on output buffering, you can
effectively send header information all throughout your file,

View file

@ -27,7 +27,7 @@ stream_filter_append($fp, "myfilter");
fwrite($fp, "This is a test.\n");
print "Done.\n";
fclose($fp);
// Uncommenting the following 'print' line causes the segfault to stop occuring
// Uncommenting the following 'print' line causes the segfault to stop occurring
// print "2\n";
readfile(dirname(__FILE__)."/test.txt");
unlink(dirname(__FILE__)."/test.txt");

View file

@ -53,7 +53,7 @@ class TheObj {
unset($SomeObj->Virtual1);
unset($SomeObj->{'Virtual'.(3)});
//but, these variables are still available??? eventhough they're "unset"-ed
//but, these variables are still available??? even though they're "unset"-ed
print $SomeObj->Virtual1."\n";
print $SomeObj->{'Virtual'.(3)}."\n";
?>

View file

@ -39,6 +39,14 @@ include $filename;
echo "Done\n";
?>
--CLEAN--
<?php
$filename = dirname(__FILE__)."/bug38779.txt";
if (file_exists($filename)) {
@unlink(dirname(__FILE__)."/bug38779.txt");
}
?>
--EXPECTF--
Parse error: %s error%sin %s on line %d
string(6) "flush!"

View file

@ -1,5 +1,5 @@
--TEST--
Bug #40809 (Poor perfomance of ".=")
Bug #40809 (Poor performance of ".=")
--FILE--
<?php
error_reporting(E_ALL|E_STRICT);

View file

@ -1,5 +1,5 @@
--TEST--
Bug #43200 (Interface implementation / inheritence not possible in abstract classes)
Bug #43200 (Interface implementation / inheritance not possible in abstract classes)
--FILE--
<?php

View file

@ -1,5 +1,5 @@
--TEST--
Bug #43200.2 (Interface implementation / inheritence not possible in abstract classes)
Bug #43200.2 (Interface implementation / inheritance not possible in abstract classes)
--FILE--
<?php

23
Zend/tests/bug65419.phpt Normal file
View file

@ -0,0 +1,23 @@
--TEST--
Bug #65419 (Inside trait, self::class != __CLASS__)
--FILE--
<?php
trait abc
{
static function def()
{
echo self::class, "\n";
echo __CLASS__, "\n";
}
}
class ghi
{
use abc;
}
ghi::def();
?>
--EXPECTF--
ghi
ghi

18
Zend/tests/bug68370.phpt Normal file
View file

@ -0,0 +1,18 @@
--TEST--
Bug #68370 "unset($this)" can make the program crash
--FILE--
<?php
class C {
public function test() {
unset($this);
return get_defined_vars();
}
}
$c = new C();
$x = $c->test();
print_r($x);
unset($c, $x);
--EXPECTF--
Array
(
)

36
Zend/tests/bug68446.phpt Normal file
View file

@ -0,0 +1,36 @@
--TEST--
Bug #68446 (Array constant not accepted for array parameter default)
--FILE--
<?php
const FOO = [1];
const BAR = null;
function a(array $a = FOO) {
var_dump($a);
}
function b(array $b = BAR) {
var_dump($b);
}
b(null);
b([]);
b();
a([]);
a();
a(null);
?>
--EXPECTF--
NULL
array(0) {
}
NULL
array(0) {
}
array(1) {
[0]=>
int(1)
}
Catchable fatal error: Argument 1 passed to a() must be of the type array, null given, called in %s on line %d and defined in %s on line %d

View file

@ -0,0 +1,25 @@
--TEST--
Const class properties(runtime cache)
--FILE--
<?php
class A {
}
$a = new A;
echo "runtime\n";
var_dump($a->{array()});
var_dump($a->{1});
var_dump($a->{function(){}});
?>
--EXPECTF--
Notice: Array to string conversion in %sclass_properties_const.php on line %d
runtime
Notice: Undefined property: A::$Array in %sclass_properties_const.php on line %d
NULL
Notice: Undefined property: A::$1 in %sclass_properties_const.php on line %d
NULL
Catchable fatal error: Object of class Closure could not be converted to string in %sclass_properties_const.php on line %d

View file

@ -23,15 +23,15 @@ set_error_handler(function($code, $msg, $file, $line) {
});
try {
(new CL())->load('class://non.existant.Class');
(new CL())->load('class://non.existent.Class');
} catch (CLException $e) {
echo $e."\n";
}
--EXPECTF--
ERR#2: include(class://non.existant.Class): failed to open stream: "CLWrapper::stream_open" call failed @ include
ERR#2: include(): Failed opening 'class://non.existant.Class' for inclusion (include_path='%s') @ include
ERR#2: include(class://non.existent.Class): failed to open stream: "CLWrapper::stream_open" call failed @ include
ERR#2: include(): Failed opening 'class://non.existent.Class' for inclusion (include_path='%s') @ include
Fatal error: Uncaught exception 'Exception' with message 'Failed loading class://non.existant.Class' in %s
Fatal error: Uncaught exception 'Exception' with message 'Failed loading class://non.existent.Class' in %s
Stack trace:
#0 %s(%d): CL->load('class://non.exi...')
#1 {main}

View file

@ -16,4 +16,4 @@ class Boo {
?>
--EXPECTF--
Fatal error: The modifiers for the trait alias dontKnow() need to be changed in the same statment in which the alias is defined. Error in %s on line %d
Fatal error: The modifiers for the trait alias dontKnow() need to be changed in the same statement in which the alias is defined. Error in %s on line %d

View file

@ -1,5 +1,5 @@
--TEST--
Try finally (function call in the finaly block after exception)
Try finally (function call in the finally block after exception)
--FILE--
<?php
function foo() {

View file

@ -1,5 +1,5 @@
--TEST--
Passing a dimention fetch on a temporary by reference is not allowed
Passing a dimension fetch on a temporary by reference is not allowed
--FILE--
<?php

View file

@ -51,7 +51,7 @@ ZEND_API int zend_get_parameters(int ht, int param_count, ...) /* {{{ */
TSRMLS_FETCH();
param_ptr = ZEND_CALL_ARG(EG(current_execute_data), 1);
arg_count = EG(current_execute_data)->num_args;
arg_count = ZEND_CALL_NUM_ARGS(EG(current_execute_data));
if (param_count>arg_count) {
return FAILURE;
@ -87,7 +87,7 @@ ZEND_API int zend_get_parameters_ex(int param_count, ...) /* {{{ */
TSRMLS_FETCH();
param_ptr = ZEND_CALL_ARG(EG(current_execute_data), 1);
arg_count = EG(current_execute_data)->num_args;
arg_count = ZEND_CALL_NUM_ARGS(EG(current_execute_data));
if (param_count>arg_count) {
return FAILURE;
@ -111,7 +111,7 @@ ZEND_API int _zend_get_parameters_array_ex(int param_count, zval *argument_array
int arg_count;
param_ptr = ZEND_CALL_ARG(EG(current_execute_data), 1);
arg_count = EG(current_execute_data)->num_args;
arg_count = ZEND_CALL_NUM_ARGS(EG(current_execute_data));
if (param_count>arg_count) {
return FAILURE;
@ -133,7 +133,7 @@ ZEND_API int zend_copy_parameters_array(int param_count, zval *argument_array TS
int arg_count;
param_ptr = ZEND_CALL_ARG(EG(current_execute_data), 1);
arg_count = EG(current_execute_data)->num_args;
arg_count = ZEND_CALL_NUM_ARGS(EG(current_execute_data));
if (param_count>arg_count) {
return FAILURE;
@ -924,7 +924,7 @@ static int zend_parse_va_args(int num_args, const char *type_spec, va_list *va,
return FAILURE;
}
arg_count = EG(current_execute_data)->num_args;
arg_count = ZEND_CALL_NUM_ARGS(EG(current_execute_data));
if (num_args > arg_count) {
zend_error(E_WARNING, "%s(): could not obtain parameters for parsing",
@ -4131,7 +4131,7 @@ ZEND_API void zend_ctor_make_null(zend_execute_data *execute_data) /* {{{ */
if (ex->func) {
if (ZEND_USER_CODE(ex->func->type)) {
if (ex->func->op_array.this_var != -1) {
zval *this_var = EX_VAR_2(ex, ex->func->op_array.this_var);
zval *this_var = ZEND_CALL_VAR(ex, ex->func->op_array.this_var);
if (this_var != EX(return_value)) {
zval_ptr_dtor(this_var);
ZVAL_NULL(this_var);

View file

@ -346,8 +346,8 @@ ZEND_API char *zend_get_type_by_const(int type);
#define WRONG_PARAM_COUNT ZEND_WRONG_PARAM_COUNT()
#define WRONG_PARAM_COUNT_WITH_RETVAL(ret) ZEND_WRONG_PARAM_COUNT_WITH_RETVAL(ret)
#define ARG_COUNT(dummy) EX(num_args)
#define ZEND_NUM_ARGS() EX(num_args)
#define ARG_COUNT(dummy) EX_NUM_ARGS()
#define ZEND_NUM_ARGS() EX_NUM_ARGS()
#define ZEND_WRONG_PARAM_COUNT() { zend_wrong_param_count(TSRMLS_C); return; }
#define ZEND_WRONG_PARAM_COUNT_WITH_RETVAL(ret) { zend_wrong_param_count(TSRMLS_C); return ret; }
@ -712,7 +712,7 @@ ZEND_API int _z_param_class(zval *arg, zend_class_entry **pce, int num, int chec
const int _flags = (flags); \
int _min_num_args = (min_num_args); \
int _max_num_args = (max_num_args); \
int _num_args = EX(num_args); \
int _num_args = EX_NUM_ARGS(); \
int _i; \
zval *_real_arg, *_arg = NULL; \
zend_expected_type _expected_type = IS_UNDEF; \

View file

@ -30,7 +30,7 @@
* performed using mmap(). The result is aligned on 2M boundary.
*
* Large - a number of 4096K pages inside a CHUNK. Large blocks
* are always alligned on page boundary.
* are always aligned on page boundary.
*
* Small - less than 3/4 of page size. Small sizes are rounded up to nearest
* greater predefined small size (there are 30 predefined sizes:
@ -272,7 +272,7 @@ struct _zend_mm_page {
};
/*
* bin - is one or few continuous pages (up to 8) used for alocation of
* bin - is one or few continuous pages (up to 8) used for allocation of
* a particular "small size".
*/
struct _zend_mm_bin {
@ -395,10 +395,10 @@ stderr_last_error(char *msg)
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
(LPSTR)&buf,
0, NULL)) {
fprintf(stderr, "\n%s: [0x%08x]\n", msg, err);
fprintf(stderr, "\n%s: [0x%08lx]\n", msg, err);
}
else {
fprintf(stderr, "\n%s: [0x%08x] %s\n", msg, err, buf);
fprintf(stderr, "\n%s: [0x%08lx] %s\n", msg, err, buf);
}
}
#endif
@ -2130,6 +2130,7 @@ ZEND_API void* ZEND_FASTCALL _emalloc_huge(size_t size)
return zend_mm_alloc_huge(AG(mm_heap), size);
}
#if ZEND_DEBUG
# define _ZEND_BIN_FREE(_num, _size, _elements, _pages, x, y) \
ZEND_API void ZEND_FASTCALL _efree_ ## _size(void *ptr) { \
TSRMLS_FETCH(); \
@ -2144,6 +2145,18 @@ ZEND_API void* ZEND_FASTCALL _emalloc_huge(size_t size)
zend_mm_free_small(AG(mm_heap), ptr, _num); \
} \
}
#else
# define _ZEND_BIN_FREE(_num, _size, _elements, _pages, x, y) \
ZEND_API void ZEND_FASTCALL _efree_ ## _size(void *ptr) { \
TSRMLS_FETCH(); \
ZEND_MM_CUSTOM_DEALLOCATOR(ptr); \
{ \
zend_mm_chunk *chunk = (zend_mm_chunk*)ZEND_MM_ALIGNED_BASE(ptr, ZEND_MM_CHUNK_SIZE); \
ZEND_MM_CHECK(chunk->heap == AG(mm_heap), "zend_mm_heap corrupted"); \
zend_mm_free_small(AG(mm_heap), ptr, _num); \
} \
}
#endif
ZEND_MM_BINS_INFO(_ZEND_BIN_FREE, x, y)

View file

@ -402,8 +402,8 @@ ZEND_FUNCTION(func_num_args)
{
zend_execute_data *ex = EX(prev_execute_data);
if (VM_FRAME_KIND(ex->frame_info) == VM_FRAME_NESTED_FUNCTION || VM_FRAME_KIND(ex->frame_info) == VM_FRAME_TOP_FUNCTION) {
RETURN_LONG(ex->num_args);
if (!(ZEND_CALL_INFO(ex) & ZEND_CALL_CODE)) {
RETURN_LONG(ZEND_CALL_NUM_ARGS(ex));
} else {
zend_error(E_WARNING, "func_num_args(): Called from the global scope - no function context");
RETURN_LONG(-1);
@ -430,12 +430,12 @@ ZEND_FUNCTION(func_get_arg)
}
ex = EX(prev_execute_data);
if (VM_FRAME_KIND(ex->frame_info) != VM_FRAME_NESTED_FUNCTION && VM_FRAME_KIND(ex->frame_info) != VM_FRAME_TOP_FUNCTION) {
if (ZEND_CALL_INFO(ex) & ZEND_CALL_CODE) {
zend_error(E_WARNING, "func_get_arg(): Called from the global scope - no function context");
RETURN_FALSE;
}
arg_count = ex->num_args;
arg_count = ZEND_CALL_NUM_ARGS(ex);
if (requested_offset >= arg_count) {
zend_error(E_WARNING, "func_get_arg(): Argument " ZEND_LONG_FMT " not passed to function", requested_offset);
@ -446,8 +446,8 @@ ZEND_FUNCTION(func_get_arg)
if (ex->func->op_array.fn_flags & ZEND_ACC_VARIADIC) {
first_extra_arg--;
}
if (requested_offset >= first_extra_arg && (ex->num_args > first_extra_arg)) {
arg = EX_VAR_NUM_2(ex, ex->func->op_array.last_var + ex->func->op_array.T) + (requested_offset - first_extra_arg);
if (requested_offset >= first_extra_arg && (ZEND_CALL_NUM_ARGS(ex) > first_extra_arg)) {
arg = ZEND_CALL_VAR_NUM(ex, ex->func->op_array.last_var + ex->func->op_array.T) + (requested_offset - first_extra_arg);
} else {
arg = ZEND_CALL_ARG(ex, requested_offset + 1);
}
@ -464,12 +464,12 @@ ZEND_FUNCTION(func_get_args)
uint32_t i;
zend_execute_data *ex = EX(prev_execute_data);
if (VM_FRAME_KIND(ex->frame_info) != VM_FRAME_NESTED_FUNCTION && VM_FRAME_KIND(ex->frame_info) != VM_FRAME_TOP_FUNCTION) {
if (ZEND_CALL_INFO(ex) & ZEND_CALL_CODE) {
zend_error(E_WARNING, "func_get_args(): Called from the global scope - no function context");
RETURN_FALSE;
}
arg_count = ex->num_args;
arg_count = ZEND_CALL_NUM_ARGS(ex);
array_init_size(return_value, arg_count);
if (arg_count) {
@ -483,7 +483,7 @@ ZEND_FUNCTION(func_get_args)
i = 0;
q = Z_ARRVAL_P(return_value)->arData;
p = ZEND_CALL_ARG(ex, 1);
if (ex->num_args > first_extra_arg) {
if (ZEND_CALL_NUM_ARGS(ex) > first_extra_arg) {
while (i < first_extra_arg) {
q->h = i;
q->key = NULL;
@ -496,7 +496,7 @@ ZEND_FUNCTION(func_get_args)
q++;
i++;
}
p = EX_VAR_NUM_2(ex, ex->func->op_array.last_var + ex->func->op_array.T);
p = ZEND_CALL_VAR_NUM(ex, ex->func->op_array.last_var + ex->func->op_array.T);
}
while (i < arg_count) {
q->h = i;
@ -2050,7 +2050,7 @@ ZEND_FUNCTION(get_defined_constants)
static void debug_backtrace_get_args(zend_execute_data *call, zval *arg_array TSRMLS_DC) /* {{{ */
{
uint32_t num_args = call->num_args;
uint32_t num_args = ZEND_CALL_NUM_ARGS(call);
array_init_size(arg_array, num_args);
if (num_args) {
@ -2063,14 +2063,14 @@ static void debug_backtrace_get_args(zend_execute_data *call, zval *arg_array TS
if (call->func->op_array.fn_flags & ZEND_ACC_VARIADIC) {
first_extra_arg--;
}
if (call->num_args > first_extra_arg) {
if (ZEND_CALL_NUM_ARGS(call) > first_extra_arg) {
while (i < first_extra_arg) {
if (Z_REFCOUNTED_P(p)) Z_ADDREF_P(p);
zend_hash_next_index_insert_new(Z_ARRVAL_P(arg_array), p);
p++;
i++;
}
p = EX_VAR_NUM_2(call, call->func->op_array.last_var + call->func->op_array.T);
p = ZEND_CALL_VAR_NUM(call, call->func->op_array.last_var + call->func->op_array.T);
}
}

View file

@ -159,6 +159,7 @@ void zend_init_compiler_context(TSRMLS_D) /* {{{ */
CG(context).current_brk_cont = -1;
CG(context).backpatch_count = 0;
CG(context).in_finally = 0;
CG(context).fast_call_var = -1;
CG(context).labels = NULL;
}
/* }}} */
@ -272,7 +273,7 @@ static int lookup_cv(zend_op_array *op_array, zend_string* name TSRMLS_DC) /* {{
op_array->vars[i]->len == name->len &&
memcmp(op_array->vars[i]->val, name->val, name->len) == 0)) {
zend_string_release(name);
return (int)(zend_intptr_t)EX_VAR_NUM_2(NULL, i);
return (int)(zend_intptr_t)ZEND_CALL_VAR_NUM(NULL, i);
}
i++;
}
@ -284,7 +285,7 @@ static int lookup_cv(zend_op_array *op_array, zend_string* name TSRMLS_DC) /* {{
}
op_array->vars[i] = zend_new_interned_string(name TSRMLS_CC);
return (int)(zend_intptr_t)EX_VAR_NUM_2(NULL, i);
return (int)(zend_intptr_t)ZEND_CALL_VAR_NUM(NULL, i);
}
/* }}} */
@ -1810,7 +1811,7 @@ static inline uint32_t zend_delayed_compile_begin(TSRMLS_D) /* {{{ */
static zend_op *zend_delayed_compile_end(uint32_t offset TSRMLS_DC) /* {{{ */
{
zend_op *opline, *oplines = zend_stack_base(&CG(delayed_oplines_stack));
zend_op *opline = NULL, *oplines = zend_stack_base(&CG(delayed_oplines_stack));
uint32_t i, count = zend_stack_count(&CG(delayed_oplines_stack));
ZEND_ASSERT(count > offset);
@ -2109,7 +2110,8 @@ static zend_op *zend_delayed_compile_prop(znode *result, zend_ast *ast, uint32_t
zend_compile_expr(&prop_node, prop_ast TSRMLS_CC);
opline = zend_delayed_emit_op(result, ZEND_FETCH_OBJ_R, &obj_node, &prop_node TSRMLS_CC);
if (opline->op2_type == IS_CONST && Z_TYPE(CONSTANT(opline->op2.constant)) == IS_STRING) {
if (opline->op2_type == IS_CONST) {
convert_to_string(&CONSTANT(opline->op2.constant));
zend_alloc_polymorphic_cache_slot(opline->op2.constant TSRMLS_CC);
}
@ -2477,7 +2479,12 @@ uint32_t zend_compile_args(zend_ast *ast, zend_function *fbc TSRMLS_DC) /* {{{ *
if (fbc) {
flags |= ZEND_ARG_COMPILE_TIME_BOUND;
}
opline->extended_value = flags;
if ((flags & ZEND_ARG_COMPILE_TIME_BOUND) && !(flags & ZEND_ARG_SEND_BY_REF)) {
opline->opcode = ZEND_SEND_VAR;
opline->extended_value = ZEND_ARG_COMPILE_TIME_BOUND;
} else {
opline->extended_value = flags;
}
} else if (fbc) {
opline->extended_value = ZEND_ARG_COMPILE_TIME_BOUND;
}
@ -2984,9 +2991,7 @@ void zend_compile_global_var(zend_ast *ast TSRMLS_DC) /* {{{ */
zend_compile_expr(&name_node, name_ast TSRMLS_CC);
if (name_node.op_type == IS_CONST) {
if (Z_TYPE(name_node.u.constant) != IS_STRING) {
convert_to_string(&name_node.u.constant);
}
convert_to_string(&name_node.u.constant);
}
if (zend_try_compile_cv(&result, var_ast TSRMLS_CC) == SUCCESS) {
@ -3122,7 +3127,9 @@ void zend_compile_return(zend_ast *ast TSRMLS_DC) /* {{{ */
zend_free_foreach_and_switch_variables(TSRMLS_C);
if (CG(context).in_finally) {
zend_emit_op(NULL, ZEND_DISCARD_EXCEPTION, NULL, NULL TSRMLS_CC);
opline = zend_emit_op(NULL, ZEND_DISCARD_EXCEPTION, NULL, NULL TSRMLS_CC);
opline->op1_type = IS_TMP_VAR;
opline->op1.var = CG(context).fast_call_var;
}
opline = zend_emit_op(NULL, by_ref ? ZEND_RETURN_BY_REF : ZEND_RETURN,
@ -3427,7 +3434,7 @@ void zend_compile_if(zend_ast *ast TSRMLS_DC) /* {{{ */
{
zend_ast_list *list = zend_ast_get_list(ast);
uint32_t i;
uint32_t *jmp_opnums;
uint32_t *jmp_opnums = NULL;
if (list->children > 1) {
jmp_opnums = safe_emalloc(sizeof(uint32_t), list->children - 1, 0);
@ -3617,8 +3624,15 @@ void zend_compile_try(zend_ast *ast TSRMLS_DC) /* {{{ */
if (finally_ast) {
uint32_t opnum_jmp = get_next_op_number(CG(active_op_array)) + 1;
if (!(CG(active_op_array)->fn_flags & ZEND_ACC_HAS_FINALLY_BLOCK)) {
CG(active_op_array)->fn_flags |= ZEND_ACC_HAS_FINALLY_BLOCK;
CG(context).fast_call_var = get_temporary_variable(CG(active_op_array));
}
opline = zend_emit_op(NULL, ZEND_FAST_CALL, NULL, NULL TSRMLS_CC);
opline->op1.opline_num = opnum_jmp + 1;
opline->result_type = IS_TMP_VAR;
opline->result.var = CG(context).fast_call_var;
zend_emit_op(NULL, ZEND_JMP, NULL, NULL TSRMLS_CC);
@ -3629,9 +3643,10 @@ void zend_compile_try(zend_ast *ast TSRMLS_DC) /* {{{ */
CG(active_op_array)->try_catch_array[try_catch_offset].finally_op = opnum_jmp + 1;
CG(active_op_array)->try_catch_array[try_catch_offset].finally_end
= get_next_op_number(CG(active_op_array));
CG(active_op_array)->fn_flags |= ZEND_ACC_HAS_FINALLY_BLOCK;
zend_emit_op(NULL, ZEND_FAST_RET, NULL, NULL TSRMLS_CC);
opline = zend_emit_op(NULL, ZEND_FAST_RET, NULL, NULL TSRMLS_CC);
opline->op1_type = IS_TMP_VAR;
opline->op1.var = CG(context).fast_call_var;
zend_update_jump_target_to_next(opnum_jmp TSRMLS_CC);
}
@ -3830,8 +3845,7 @@ void zend_compile_params(zend_ast *ast TSRMLS_DC) /* {{{ */
zend_bool has_null_default = default_ast
&& (Z_TYPE(default_node.u.constant) == IS_NULL
|| (Z_TYPE(default_node.u.constant) == IS_CONSTANT
&& strcasecmp(Z_STRVAL(default_node.u.constant), "NULL") == 0)
|| Z_TYPE(default_node.u.constant) == IS_CONSTANT_AST); // ???
&& strcasecmp(Z_STRVAL(default_node.u.constant), "NULL") == 0));
op_array->fn_flags |= ZEND_ACC_HAS_TYPE_HINTS;
arg_info->allow_null = has_null_default;
@ -3841,12 +3855,13 @@ void zend_compile_params(zend_ast *ast TSRMLS_DC) /* {{{ */
if (arg_info->type_hint == IS_ARRAY) {
if (default_ast && !has_null_default
&& Z_TYPE(default_node.u.constant) != IS_ARRAY
&& !Z_CONSTANT(default_node.u.constant)
) {
zend_error_noreturn(E_COMPILE_ERROR, "Default value for parameters "
"with array type hint can only be an array or NULL");
}
} else if (arg_info->type_hint == IS_CALLABLE && default_ast) {
if (!has_null_default) {
if (!has_null_default && !Z_CONSTANT(default_node.u.constant)) {
zend_error_noreturn(E_COMPILE_ERROR, "Default value for parameters "
"with callable type hint can only be NULL");
}
@ -3866,7 +3881,7 @@ void zend_compile_params(zend_ast *ast TSRMLS_DC) /* {{{ */
zend_string_release(class_name);
if (default_ast && !has_null_default) {
if (default_ast && !has_null_default && !Z_CONSTANT(default_node.u.constant)) {
zend_error_noreturn(E_COMPILE_ERROR, "Default value for parameters "
"with a class type hint can only be NULL");
}
@ -5469,7 +5484,7 @@ void zend_compile_isset_or_empty(znode *result, zend_ast *ast TSRMLS_DC) /* {{{
zend_ast *var_ast = ast->child[0];
znode var_node;
zend_op *opline;
zend_op *opline = NULL;
ZEND_ASSERT(ast->kind == ZEND_AST_ISSET || ast->kind == ZEND_AST_EMPTY);
@ -5520,13 +5535,11 @@ void zend_compile_silence(znode *result, zend_ast *ast TSRMLS_DC) /* {{{ */
{
zend_ast *expr_ast = ast->child[0];
znode silence_node;
uint32_t opline_num;
zend_op *begin_silence, *end_silence;
uint32_t begin_opline_num, end_opline_num;
zend_brk_cont_element *brk_cont_element;
opline_num = get_next_op_number(CG(active_op_array));
begin_silence = zend_emit_op_tmp(&silence_node, ZEND_BEGIN_SILENCE, NULL, NULL TSRMLS_CC);
/* pair BEGIN_SILENCE and END_SILENCE opcodes */
begin_silence->op2.num = opline_num;
begin_opline_num = get_next_op_number(CG(active_op_array));
zend_emit_op_tmp(&silence_node, ZEND_BEGIN_SILENCE, NULL, NULL TSRMLS_CC);
if (expr_ast->kind == ZEND_AST_VAR) {
/* For @$var we need to force a FETCH instruction, otherwise the CV access will
@ -5536,9 +5549,15 @@ void zend_compile_silence(znode *result, zend_ast *ast TSRMLS_DC) /* {{{ */
zend_compile_expr(result, expr_ast TSRMLS_CC);
}
end_silence = zend_emit_op(NULL, ZEND_END_SILENCE, &silence_node, NULL TSRMLS_CC);
/* pair BEGIN_SILENCE and END_SILENCE opcodes */
end_silence->op2.num = opline_num;
end_opline_num = get_next_op_number(CG(active_op_array));
zend_emit_op(NULL, ZEND_END_SILENCE, &silence_node, NULL TSRMLS_CC);
/* Store BEGIN_SILENCE/END_SILENCE pair to restore previous
* EG(error_reporting) value on exception */
brk_cont_element = get_next_brk_cont_element(CG(active_op_array));
brk_cont_element->start = begin_opline_num;
brk_cont_element->cont = brk_cont_element->brk = end_opline_num;
brk_cont_element->parent = -1;
}
/* }}} */
@ -5701,8 +5720,21 @@ void zend_compile_resolve_class_name(znode *result, zend_ast *ast TSRMLS_DC) /*
zend_error_noreturn(E_COMPILE_ERROR,
"Cannot access self::class when no class scope is active");
}
result->op_type = IS_CONST;
ZVAL_STR_COPY(&result->u.constant, CG(active_class_entry)->name);
if (CG(active_class_entry)->ce_flags & ZEND_ACC_TRAIT) {
zval class_str_zv;
zend_ast *class_str_ast, *class_const_ast;
ZVAL_STRING(&class_str_zv, "class");
class_str_ast = zend_ast_create_zval(&class_str_zv);
class_const_ast = zend_ast_create(ZEND_AST_CLASS_CONST, name_ast, class_str_ast);
zend_compile_expr(result, class_const_ast TSRMLS_CC);
zval_ptr_dtor(&class_str_zv);
} else {
result->op_type = IS_CONST;
ZVAL_STR_COPY(&result->u.constant, CG(active_class_entry)->name);
}
break;
case ZEND_FETCH_CLASS_STATIC:
case ZEND_FETCH_CLASS_PARENT:
@ -5788,14 +5820,14 @@ void zend_compile_encaps_list(znode *result, zend_ast *ast TSRMLS_DC) /* {{{ */
void zend_compile_magic_const(znode *result, zend_ast *ast TSRMLS_DC) /* {{{ */
{
zend_class_entry *ce = CG(active_class_entry);
if (zend_try_ct_eval_magic_const(&result->u.constant, ast TSRMLS_CC)) {
result->op_type = IS_CONST;
return;
}
ZEND_ASSERT(ast->attr == T_CLASS_C && ce && ZEND_CE_IS_TRAIT(ce));
ZEND_ASSERT(ast->attr == T_CLASS_C &&
CG(active_class_entry) &&
ZEND_CE_IS_TRAIT(CG(active_class_entry)));
{
zend_ast *const_ast = zend_ast_create(ZEND_AST_CONST,
@ -5926,10 +5958,11 @@ void zend_compile_const_expr_resolve_class_name(zend_ast **ast_ptr TSRMLS_DC) /*
void zend_compile_const_expr_magic_const(zend_ast **ast_ptr TSRMLS_DC) /* {{{ */
{
zend_ast *ast = *ast_ptr;
zend_class_entry *ce = CG(active_class_entry);
/* Other cases already resolved by constant folding */
ZEND_ASSERT(ast->attr == T_CLASS_C && ce && ZEND_CE_IS_TRAIT(ce));
ZEND_ASSERT(ast->attr == T_CLASS_C &&
CG(active_class_entry) &&
ZEND_CE_IS_TRAIT(CG(active_class_entry)));
{
zval const_zv;

View file

@ -52,6 +52,7 @@ typedef struct _zend_compiler_context {
int current_brk_cont;
int backpatch_count;
int in_finally;
uint32_t fast_call_var;
HashTable *labels;
} zend_compiler_context;
@ -356,12 +357,12 @@ union _zend_function {
zend_internal_function internal_function;
};
typedef enum _vm_frame_kind {
VM_FRAME_NESTED_FUNCTION, /* stackless VM call to function */
VM_FRAME_NESTED_CODE, /* stackless VM call to include/require/eval */
VM_FRAME_TOP_FUNCTION, /* direct VM call to function from external C code */
VM_FRAME_TOP_CODE /* direct VM call to "main" code from external C code */
} vm_frame_kind;
typedef enum _zend_call_kind {
ZEND_CALL_NESTED_FUNCTION, /* stackless VM call to function */
ZEND_CALL_NESTED_CODE, /* stackless VM call to include/require/eval */
ZEND_CALL_TOP_FUNCTION, /* direct VM call to function from external C code */
ZEND_CALL_TOP_CODE /* direct VM call to "main" code from external C code */
} zend_call_kind;
struct _zend_execute_data {
const zend_op *opline; /* executed opline */
@ -371,42 +372,56 @@ struct _zend_execute_data {
zval This;
zend_class_entry *called_scope;
zend_execute_data *prev_execute_data;
uint32_t frame_info;
uint32_t num_args;
zval *return_value;
zend_class_entry *scope; /* function scope (self) */
zend_array *symbol_table;
const zend_op *fast_ret; /* used by FAST_CALL/FAST_RET (finally keyword) */
zend_object *delayed_exception;
uint32_t silence_op_num;
uint32_t old_error_reporting;
};
#define VM_FRAME_KIND_MASK 0x000000ff
#define VM_FRAME_FLAGS_MASK 0xffffff00
#define ZEND_CALL_FUNCTION (0 << 0)
#define ZEND_CALL_CODE (1 << 0)
#define ZEND_CALL_NESTED (0 << 1)
#define ZEND_CALL_TOP (1 << 1)
#define ZEND_CALL_CTOR (1 << 2)
#define ZEND_CALL_CTOR_RESULT_UNUSED (1 << 3)
#define ZEND_CALL_CTOR (1 << 8)
#define ZEND_CALL_CTOR_RESULT_UNUSED (1 << 9)
#define ZEND_CALL_INFO(call) \
(Z_TYPE_INFO((call)->This) >> 24)
#define VM_FRAME_INFO(kind, flags) ((kind) | (flags))
#define VM_FRAME_KIND(info) ((info) & VM_FRAME_KIND_MASK)
#define VM_FRAME_FLAGS(info) ((info) & VM_FRAME_FLAGS_MASK)
#define ZEND_CALL_KIND(call) \
(ZEND_CALL_INFO(call) & (ZEND_CALL_CODE | ZEND_CALL_TOP))
#define ZEND_SET_CALL_INFO(call, info) do { \
Z_TYPE_INFO((call)->This) = IS_OBJECT_EX | ((info) << 24); \
} while (0)
#define ZEND_ADD_CALL_FLAG(call, info) do { \
Z_TYPE_INFO((call)->This) |= ((info) << 24); \
} while (0)
#define ZEND_CALL_NUM_ARGS(call) \
(call)->This.u2.num_args
#define ZEND_CALL_FRAME_SLOT \
((ZEND_MM_ALIGNED_SIZE(sizeof(zend_execute_data)) + ZEND_MM_ALIGNED_SIZE(sizeof(zval)) - 1) / ZEND_MM_ALIGNED_SIZE(sizeof(zval)))
#define ZEND_CALL_VAR(call, n) \
((zval*)(((char*)(call)) + ((int)(n))))
#define ZEND_CALL_VAR_NUM(call, n) \
(((zval*)(call)) + (ZEND_CALL_FRAME_SLOT + ((int)(n))))
#define ZEND_CALL_ARG(call, n) \
(((zval*)(call)) + ((n) + (ZEND_CALL_FRAME_SLOT - 1)))
ZEND_CALL_VAR_NUM(call, ((int)(n)) - 1)
#define EX(element) ((execute_data)->element)
#define EX_VAR_2(ex, n) ((zval*)(((char*)(ex)) + ((int)(n))))
#define EX_VAR_NUM_2(ex, n) (((zval*)(ex)) + (ZEND_CALL_FRAME_SLOT + ((int)(n))))
#define EX_CALL_INFO() ZEND_CALL_INFO(execute_data)
#define EX_CALL_KIND() ZEND_CALL_KIND(execute_data)
#define EX_NUM_ARGS() ZEND_CALL_NUM_ARGS(execute_data)
#define EX_VAR(n) EX_VAR_2(execute_data, n)
#define EX_VAR_NUM(n) EX_VAR_NUM_2(execute_data, n)
#define EX_VAR(n) ZEND_CALL_VAR(execute_data, n)
#define EX_VAR_NUM(n) ZEND_CALL_VAR_NUM(execute_data, n)
#define EX_VAR_TO_NUM(n) (EX_VAR_2(NULL, n) - EX_VAR_NUM_2(NULL, 0))
#define EX_VAR_TO_NUM(n) (ZEND_CALL_VAR(NULL, n) - ZEND_CALL_VAR_NUM(NULL, 0))
#define IS_CONST (1<<0)
#define IS_TMP_VAR (1<<1)

View file

@ -44,12 +44,12 @@ typedef struct _zend_constant {
#define REGISTER_STRING_CONSTANT(name, str, flags) zend_register_string_constant((name), sizeof(name)-1, (str), (flags), module_number TSRMLS_CC)
#define REGISTER_STRINGL_CONSTANT(name, str, len, flags) zend_register_stringl_constant((name), sizeof(name)-1, (str), (len), (flags), module_number TSRMLS_CC)
#define REGISTER_NS_NULL_CONSTANT(ns, name, flags) zend_register_null_constant(ZEND_NS_NAME(ns, name), sizeof(ZEND_NS_NAME(ns, name)), (flags), module_number TSRMLS_CC)
#define REGISTER_NS_BOOL_CONSTANT(ns, name, bval, flags) zend_register_bool_constant(ZEND_NS_NAME(ns, name), sizeof(ZEND_NS_NAME(ns, name)), (bval), (flags), module_number TSRMLS_CC)
#define REGISTER_NS_LONG_CONSTANT(ns, name, lval, flags) zend_register_long_constant(ZEND_NS_NAME(ns, name), sizeof(ZEND_NS_NAME(ns, name)), (lval), (flags), module_number TSRMLS_CC)
#define REGISTER_NS_DOUBLE_CONSTANT(ns, name, dval, flags) zend_register_double_constant(ZEND_NS_NAME(ns, name), sizeof(ZEND_NS_NAME(ns, name)), (dval), (flags), module_number TSRMLS_CC)
#define REGISTER_NS_STRING_CONSTANT(ns, name, str, flags) zend_register_string_constant(ZEND_NS_NAME(ns, name), sizeof(ZEND_NS_NAME(ns, name)), (str), (flags), module_number TSRMLS_CC)
#define REGISTER_NS_STRINGL_CONSTANT(ns, name, str, len, flags) zend_register_stringl_constant(ZEND_NS_NAME(ns, name), sizeof(ZEND_NS_NAME(ns, name)), (str), (len), (flags), module_number TSRMLS_CC)
#define REGISTER_NS_NULL_CONSTANT(ns, name, flags) zend_register_null_constant(ZEND_NS_NAME(ns, name), sizeof(ZEND_NS_NAME(ns, name))-1, (flags), module_number TSRMLS_CC)
#define REGISTER_NS_BOOL_CONSTANT(ns, name, bval, flags) zend_register_bool_constant(ZEND_NS_NAME(ns, name), sizeof(ZEND_NS_NAME(ns, name))-1, (bval), (flags), module_number TSRMLS_CC)
#define REGISTER_NS_LONG_CONSTANT(ns, name, lval, flags) zend_register_long_constant(ZEND_NS_NAME(ns, name), sizeof(ZEND_NS_NAME(ns, name))-1, (lval), (flags), module_number TSRMLS_CC)
#define REGISTER_NS_DOUBLE_CONSTANT(ns, name, dval, flags) zend_register_double_constant(ZEND_NS_NAME(ns, name), sizeof(ZEND_NS_NAME(ns, name))-1, (dval), (flags), module_number TSRMLS_CC)
#define REGISTER_NS_STRING_CONSTANT(ns, name, str, flags) zend_register_string_constant(ZEND_NS_NAME(ns, name), sizeof(ZEND_NS_NAME(ns, name))-1, (str), (flags), module_number TSRMLS_CC)
#define REGISTER_NS_STRINGL_CONSTANT(ns, name, str, len, flags) zend_register_stringl_constant(ZEND_NS_NAME(ns, name), sizeof(ZEND_NS_NAME(ns, name))-1, (str), (len), (flags), module_number TSRMLS_CC)
#define REGISTER_MAIN_NULL_CONSTANT(name, flags) zend_register_null_constant((name), sizeof(name)-1, (flags), 0 TSRMLS_CC)
#define REGISTER_MAIN_BOOL_CONSTANT(name, bval, flags) zend_register_bool_constant((name), sizeof(name)-1, (bval), (flags), 0 TSRMLS_CC)

View file

@ -99,13 +99,13 @@ static const zend_internal_function zend_pass_function = {
} while (0)
#define FREE_OP(should_free) \
if (should_free.var) { \
zval_ptr_dtor_nogc(should_free.var); \
if (should_free) { \
zval_ptr_dtor_nogc(should_free); \
}
#define FREE_OP_VAR_PTR(should_free) \
if (should_free.var) { \
zval_ptr_dtor_nogc(should_free.var); \
if (should_free) { \
zval_ptr_dtor_nogc(should_free); \
}
/* End of zend_execute_locks.h */
@ -183,29 +183,29 @@ ZEND_API zval* zend_get_compiled_variable_value(const zend_execute_data *execute
return EX_VAR(var);
}
static zend_always_inline zval *_get_zval_ptr_tmp(uint32_t var, const zend_execute_data *execute_data, zend_free_op *should_free TSRMLS_DC)
static zend_always_inline zval *_get_zval_ptr_tmp(uint32_t var, const zend_execute_data *execute_data, zend_free_op *should_free)
{
zval *ret = EX_VAR(var);
should_free->var = ret;
*should_free = ret;
ZEND_ASSERT(Z_TYPE_P(ret) != IS_REFERENCE);
return ret;
}
static zend_always_inline zval *_get_zval_ptr_var(uint32_t var, const zend_execute_data *execute_data, zend_free_op *should_free TSRMLS_DC)
static zend_always_inline zval *_get_zval_ptr_var(uint32_t var, const zend_execute_data *execute_data, zend_free_op *should_free)
{
zval *ret = EX_VAR(var);
should_free->var = ret;
*should_free = ret;
return ret;
}
static zend_always_inline zval *_get_zval_ptr_var_deref(uint32_t var, const zend_execute_data *execute_data, zend_free_op *should_free TSRMLS_DC)
static zend_always_inline zval *_get_zval_ptr_var_deref(uint32_t var, const zend_execute_data *execute_data, zend_free_op *should_free)
{
zval *ret = EX_VAR(var);
should_free->var = ret;
*should_free = ret;
ZVAL_DEREF(ret);
return ret;
}
@ -392,93 +392,71 @@ static zend_always_inline zval *_get_zval_ptr_cv_deref_BP_VAR_W(const zend_execu
static inline zval *_get_zval_ptr(int op_type, const znode_op *node, const zend_execute_data *execute_data, zend_free_op *should_free, int type TSRMLS_DC)
{
zval *ret;
switch (op_type) {
case IS_CONST:
should_free->var = NULL;
*should_free = NULL;
return node->zv;
break;
case IS_TMP_VAR:
ret = EX_VAR(node->var);
should_free->var = ret;
return ret;
break;
return _get_zval_ptr_tmp(node->var, execute_data, should_free);
case IS_VAR:
return _get_zval_ptr_var(node->var, execute_data, should_free TSRMLS_CC);
break;
case IS_UNUSED:
should_free->var = NULL;
return NULL;
break;
return _get_zval_ptr_var(node->var, execute_data, should_free);
case IS_CV:
default:
should_free->var = NULL;
*should_free = NULL;
return _get_zval_ptr_cv(execute_data, node->var, type TSRMLS_CC);
break;
default:
*should_free = NULL;
return NULL;
}
return NULL;
}
static inline zval *_get_zval_ptr_deref(int op_type, const znode_op *node, const zend_execute_data *execute_data, zend_free_op *should_free, int type TSRMLS_DC)
{
zval *ret;
switch (op_type) {
case IS_CONST:
should_free->var = NULL;
*should_free = NULL;
return node->zv;
break;
case IS_TMP_VAR:
ret = EX_VAR(node->var);
should_free->var = ret;
return ret;
break;
return _get_zval_ptr_tmp(node->var, execute_data, should_free);
case IS_VAR:
return _get_zval_ptr_var_deref(node->var, execute_data, should_free TSRMLS_CC);
break;
case IS_UNUSED:
should_free->var = NULL;
return NULL;
break;
return _get_zval_ptr_var_deref(node->var, execute_data, should_free);
case IS_CV:
default:
should_free->var = NULL;
*should_free = NULL;
return _get_zval_ptr_cv_deref(execute_data, node->var, type TSRMLS_CC);
break;
default:
*should_free = NULL;
return NULL;
}
return NULL;
}
static zend_always_inline zval *_get_zval_ptr_ptr_var(uint32_t var, const zend_execute_data *execute_data, zend_free_op *should_free TSRMLS_DC)
static zend_always_inline zval *_get_zval_ptr_ptr_var(uint32_t var, const zend_execute_data *execute_data, zend_free_op *should_free)
{
zval *ret = EX_VAR(var);
if (EXPECTED(Z_TYPE_P(ret) == IS_INDIRECT)) {
should_free->var = NULL;
return Z_INDIRECT_P(ret);
} else if (!Z_REFCOUNTED_P(ret) || Z_REFCOUNT_P(ret) == 1) {
should_free->var = ret;
return ret;
*should_free = NULL;
ret = Z_INDIRECT_P(ret);
} else {
Z_DELREF_P(ret);
should_free->var = NULL;
return ret;
*should_free = ret;
if (Z_REFCOUNTED_P(ret) && Z_REFCOUNT_P(ret) > 1) {
*should_free = NULL;
Z_DELREF_P(ret);
}
}
return ret;
}
static inline zval *_get_zval_ptr_ptr(int op_type, const znode_op *node, const zend_execute_data *execute_data, zend_free_op *should_free, int type TSRMLS_DC)
{
if (op_type == IS_CV) {
should_free->var = NULL;
*should_free = NULL;
return _get_zval_ptr_cv(execute_data, node->var, type TSRMLS_CC);
} else /* if (op_type == IS_VAR) */ {
ZEND_ASSERT(op_type == IS_VAR);
return _get_zval_ptr_ptr_var(node->var, execute_data, should_free TSRMLS_CC);
return _get_zval_ptr_ptr_var(node->var, execute_data, should_free);
}
}
static zend_always_inline zval *_get_obj_zval_ptr_unused(zend_execute_data *execute_data TSRMLS_DC)
static zend_always_inline zval *_get_obj_zval_ptr_unused(zend_execute_data *execute_data)
{
if (EXPECTED(Z_OBJ(EX(This)) != NULL)) {
return &EX(This);
@ -492,7 +470,7 @@ static inline zval *_get_obj_zval_ptr(int op_type, znode_op *op, zend_execute_da
{
if (op_type == IS_UNUSED) {
if (EXPECTED(Z_OBJ(EX(This)) != NULL)) {
should_free->var = NULL;
*should_free = NULL;
return &EX(This);
} else {
zend_error_noreturn(E_ERROR, "Using $this when not in object context");
@ -505,7 +483,7 @@ static inline zval *_get_obj_zval_ptr_ptr(int op_type, const znode_op *node, zen
{
if (op_type == IS_UNUSED) {
if (EXPECTED(Z_OBJ(EX(This)) != NULL)) {
should_free->var = NULL;
*should_free = NULL;
return &EX(This);
} else {
zend_error_noreturn(E_ERROR, "Using $this when not in object context");
@ -580,23 +558,42 @@ ZEND_API void zend_verify_arg_error(int error_type, const zend_function *zf, uin
fclass = "";
}
if (arg && zf->common.type == ZEND_USER_FUNCTION) {
ZVAL_COPY_VALUE(&old_arg, arg);
ZVAL_UNDEF(arg);
}
if (zf->common.type == ZEND_USER_FUNCTION) {
if (arg) {
ZVAL_COPY_VALUE(&old_arg, arg);
ZVAL_UNDEF(arg);
}
if (zf->common.type == ZEND_USER_FUNCTION && ptr && ptr->func && ZEND_USER_CODE(ptr->func->common.type)) {
zend_error(error_type, "Argument %d passed to %s%s%s() must %s%s, %s%s given, called in %s on line %d and defined", arg_num, fclass, fsep, fname, need_msg, need_kind, given_msg, given_kind, ptr->func->op_array.filename->val, ptr->opline->lineno);
if (ptr && ptr->func && ZEND_USER_CODE(ptr->func->common.type)) {
zend_error(error_type, "Argument %d passed to %s%s%s() must %s%s, %s%s given, called in %s on line %d and defined", arg_num, fclass, fsep, fname, need_msg, need_kind, given_msg, given_kind, ptr->func->op_array.filename->val, ptr->opline->lineno);
} else {
zend_error(error_type, "Argument %d passed to %s%s%s() must %s%s, %s%s given", arg_num, fclass, fsep, fname, need_msg, need_kind, given_msg, given_kind);
}
if (arg) {
ZVAL_COPY_VALUE(arg, &old_arg);
}
} else {
zend_error(error_type, "Argument %d passed to %s%s%s() must %s%s, %s%s given", arg_num, fclass, fsep, fname, need_msg, need_kind, given_msg, given_kind);
}
if (arg && zf->common.type == ZEND_USER_FUNCTION) {
ZVAL_COPY_VALUE(arg, &old_arg);
}
}
static void zend_verify_arg_type(zend_function *zf, uint32_t arg_num, zval *arg TSRMLS_DC)
static int is_null_constant(zval *default_value TSRMLS_DC)
{
if (Z_CONSTANT_P(default_value)) {
zval constant;
ZVAL_COPY_VALUE(&constant, default_value);
zval_update_constant(&constant, 0 TSRMLS_CC);
if (Z_TYPE(constant) == IS_NULL) {
return 1;
}
zval_dtor(&constant);
}
return 0;
}
static void zend_verify_arg_type(zend_function *zf, uint32_t arg_num, zval *arg, zval *default_value TSRMLS_DC)
{
zend_arg_info *cur_arg_info;
char *need_msg;
@ -623,18 +620,18 @@ static void zend_verify_arg_type(zend_function *zf, uint32_t arg_num, zval *arg
if (!ce || !instanceof_function(Z_OBJCE_P(arg), ce TSRMLS_CC)) {
zend_verify_arg_error(E_RECOVERABLE_ERROR, zf, arg_num, need_msg, class_name, "instance of ", Z_OBJCE_P(arg)->name->val, arg TSRMLS_CC);
}
} else if (Z_TYPE_P(arg) != IS_NULL || !cur_arg_info->allow_null) {
} else if (Z_TYPE_P(arg) != IS_NULL || !(cur_arg_info->allow_null || (default_value && is_null_constant(default_value TSRMLS_CC)))) {
need_msg = zend_verify_arg_class_kind(cur_arg_info, &class_name, &ce TSRMLS_CC);
zend_verify_arg_error(E_RECOVERABLE_ERROR, zf, arg_num, need_msg, class_name, zend_zval_type_name(arg), "", arg TSRMLS_CC);
}
} else if (cur_arg_info->type_hint) {
if (cur_arg_info->type_hint == IS_ARRAY) {
ZVAL_DEREF(arg);
if (Z_TYPE_P(arg) != IS_ARRAY && (Z_TYPE_P(arg) != IS_NULL || !cur_arg_info->allow_null)) {
if (Z_TYPE_P(arg) != IS_ARRAY && (Z_TYPE_P(arg) != IS_NULL || !(cur_arg_info->allow_null || (default_value && is_null_constant(default_value TSRMLS_CC))))) {
zend_verify_arg_error(E_RECOVERABLE_ERROR, zf, arg_num, "be of the type array", "", zend_zval_type_name(arg), "", arg TSRMLS_CC);
}
} else if (cur_arg_info->type_hint == IS_CALLABLE) {
if (!zend_is_callable(arg, IS_CALLABLE_CHECK_SILENT, NULL TSRMLS_CC) && (Z_TYPE_P(arg) != IS_NULL || !cur_arg_info->allow_null)) {
if (!zend_is_callable(arg, IS_CALLABLE_CHECK_SILENT, NULL TSRMLS_CC) && (Z_TYPE_P(arg) != IS_NULL || !(cur_arg_info->allow_null || (default_value && is_null_constant(default_value TSRMLS_CC))))) {
zend_verify_arg_error(E_RECOVERABLE_ERROR, zf, arg_num, "be callable", "", zend_zval_type_name(arg), "", arg TSRMLS_CC);
}
#if ZEND_DEBUG
@ -704,7 +701,7 @@ static void zend_verify_missing_arg(zend_execute_data *execute_data, uint32_t ar
static zend_always_inline void zend_assign_to_object(zval *retval, zval *object, uint32_t object_op_type, zval *property_name, int value_type, const znode_op *value_op, const zend_execute_data *execute_data, int opcode, void **cache_slot TSRMLS_DC)
{
zend_free_op free_value;
zval *value = get_zval_ptr(value_type, value_op, execute_data, &free_value, BP_VAR_R);
zval *value = get_zval_ptr_deref(value_type, value_op, execute_data, &free_value, BP_VAR_R);
zval tmp;
if (object_op_type != IS_UNUSED) {
@ -748,38 +745,101 @@ static zend_always_inline void zend_assign_to_object(zval *retval, zval *object,
}
}
/* separate our value if necessary */
if (value_type == IS_TMP_VAR) {
ZVAL_COPY_VALUE(&tmp, value);
value = &tmp;
} else if (value_type == IS_CONST) {
if (UNEXPECTED(Z_OPT_COPYABLE_P(value))) {
ZVAL_COPY_VALUE(&tmp, value);
zval_copy_ctor_func(&tmp);
value = &tmp;
}
} else if (Z_REFCOUNTED_P(value)) {
Z_ADDREF_P(value);
}
if (opcode == ZEND_ASSIGN_OBJ) {
if (!Z_OBJ_HT_P(object)->write_property) {
zend_error(E_WARNING, "Attempt to assign property of non-object");
if (retval) {
ZVAL_NULL(retval);
}
if (value_type == IS_CONST) {
zval_ptr_dtor(value);
}
FREE_OP(free_value);
return;
}
if (cache_slot &&
EXPECTED(Z_OBJCE_P(object) == CACHED_PTR_EX(cache_slot))) {
zend_property_info *prop_info = CACHED_PTR_EX(cache_slot + 1);
zend_object *zobj = Z_OBJ_P(object);
zval *property;
if (EXPECTED(prop_info)) {
property = OBJ_PROP(zobj, prop_info->offset);
if (Z_TYPE_P(property) != IS_UNDEF) {
fast_assign:
value = zend_assign_to_variable(property, value, value_type TSRMLS_CC);
if (retval && !EG(exception)) {
ZVAL_COPY(retval, value);
}
if (value_type == IS_VAR) {
FREE_OP(free_value);
}
return;
}
} else {
if (EXPECTED(zobj->properties != NULL)) {
property = zend_hash_find(zobj->properties, Z_STR_P(property_name));
if (property) {
goto fast_assign;
}
}
if (!zobj->ce->__set) {
if (EXPECTED(zobj->properties == NULL)) {
rebuild_object_properties(zobj);
}
/* separate our value if necessary */
if (value_type == IS_CONST) {
if (UNEXPECTED(Z_OPT_COPYABLE_P(value))) {
ZVAL_COPY_VALUE(&tmp, value);
zval_copy_ctor_func(&tmp);
value = &tmp;
}
} else if (value_type != IS_TMP_VAR &&
Z_REFCOUNTED_P(value)) {
Z_ADDREF_P(value);
}
zend_hash_add_new(zobj->properties, Z_STR_P(property_name), value);
if (retval && !EG(exception)) {
ZVAL_COPY(retval, value);
}
if (value_type == IS_VAR) {
FREE_OP(free_value);
}
return;
}
}
}
/* separate our value if necessary */
if (value_type == IS_CONST) {
if (UNEXPECTED(Z_OPT_COPYABLE_P(value))) {
ZVAL_COPY_VALUE(&tmp, value);
zval_copy_ctor_func(&tmp);
value = &tmp;
}
} else if (value_type != IS_TMP_VAR &&
Z_REFCOUNTED_P(value)) {
Z_ADDREF_P(value);
}
Z_OBJ_HT_P(object)->write_property(object, property_name, value, cache_slot TSRMLS_CC);
} else {
/* Note: property_name in this case is really the array index! */
if (!Z_OBJ_HT_P(object)->write_dimension) {
zend_error_noreturn(E_ERROR, "Cannot use object as array");
}
/* separate our value if necessary */
if (value_type == IS_CONST) {
if (UNEXPECTED(Z_OPT_COPYABLE_P(value))) {
ZVAL_COPY_VALUE(&tmp, value);
zval_copy_ctor_func(&tmp);
value = &tmp;
}
} else if (value_type != IS_TMP_VAR &&
Z_REFCOUNTED_P(value)) {
Z_ADDREF_P(value);
}
Z_OBJ_HT_P(object)->write_dimension(object, property_name, value TSRMLS_CC);
}
@ -842,65 +902,6 @@ static void zend_assign_to_string_offset(zval *str, zend_long offset, zval *valu
}
}
static zend_always_inline zval* zend_assign_to_variable(zval *variable_ptr, zval *value, zend_uchar value_type TSRMLS_DC)
{
do {
if (UNEXPECTED(Z_REFCOUNTED_P(variable_ptr))) {
zend_refcounted *garbage;
if (Z_ISREF_P(variable_ptr)) {
variable_ptr = Z_REFVAL_P(variable_ptr);
if (EXPECTED(!Z_REFCOUNTED_P(variable_ptr))) {
break;
}
}
if (Z_TYPE_P(variable_ptr) == IS_OBJECT &&
UNEXPECTED(Z_OBJ_HANDLER_P(variable_ptr, set) != NULL)) {
Z_OBJ_HANDLER_P(variable_ptr, set)(variable_ptr, value TSRMLS_CC);
return variable_ptr;
}
if ((value_type & (IS_VAR|IS_CV)) && variable_ptr == value) {
return variable_ptr;
}
garbage = Z_COUNTED_P(variable_ptr);
if (--GC_REFCOUNT(garbage) == 0) {
ZVAL_COPY_VALUE(variable_ptr, value);
if (value_type == IS_CONST) {
/* IS_CONST can't be IS_OBJECT, IS_RESOURCE or IS_REFERENCE */
if (UNEXPECTED(Z_OPT_COPYABLE_P(variable_ptr))) {
zval_copy_ctor_func(variable_ptr);
}
} else if (value_type != IS_TMP_VAR) {
if (UNEXPECTED(Z_OPT_REFCOUNTED_P(variable_ptr))) {
Z_ADDREF_P(variable_ptr);
}
}
_zval_dtor_func_for_ptr(garbage ZEND_FILE_LINE_CC);
return variable_ptr;
} else { /* we need to split */
/* optimized version of GC_ZVAL_CHECK_POSSIBLE_ROOT(variable_ptr) */
if ((Z_COLLECTABLE_P(variable_ptr)) &&
UNEXPECTED(!GC_INFO(garbage))) {
gc_possible_root(garbage TSRMLS_CC);
}
}
}
} while (0);
ZVAL_COPY_VALUE(variable_ptr, value);
if (value_type == IS_CONST) {
/* IS_CONST can't be IS_OBJECT, IS_RESOURCE or IS_REFERENCE */
if (UNEXPECTED(Z_OPT_COPYABLE_P(variable_ptr))) {
zval_copy_ctor_func(variable_ptr);
}
} else if (value_type != IS_TMP_VAR) {
if (UNEXPECTED(Z_OPT_REFCOUNTED_P(variable_ptr))) {
Z_ADDREF_P(variable_ptr);
}
}
return variable_ptr;
}
/* Utility Functions for Extensions */
static void zend_extension_statement_handler(const zend_extension *extension, zend_op_array *op_array TSRMLS_DC)
{
@ -1429,12 +1430,12 @@ ZEND_API void execute_internal(zend_execute_data *execute_data, zval *return_val
ZEND_API void zend_clean_and_cache_symbol_table(zend_array *symbol_table TSRMLS_DC) /* {{{ */
{
if (EG(symtable_cache_ptr) >= EG(symtable_cache_limit)) {
zend_hash_destroy(&symbol_table->ht);
zend_array_destroy(&symbol_table->ht TSRMLS_CC);
efree_size(symbol_table, sizeof(zend_array));
} else {
/* clean before putting into the cache, since clean
could call dtors, which could use cached hash */
zend_hash_clean(&symbol_table->ht);
zend_symtable_clean(&symbol_table->ht TSRMLS_CC);
*(++EG(symtable_cache_ptr)) = symbol_table;
}
}
@ -1483,20 +1484,17 @@ static zend_always_inline void i_init_func_execute_data(zend_execute_data *execu
{
uint32_t first_extra_arg, num_args;
ZEND_ASSERT(EX(func) == (zend_function*)op_array);
ZEND_ASSERT(EX(scope) == EG(scope));
EX(opline) = op_array->opcodes;
EX(call) = NULL;
EX(return_value) = return_value;
EX(delayed_exception) = NULL;
EX(silence_op_num) = -1;
/* Handle arguments */
first_extra_arg = op_array->num_args;
if (UNEXPECTED((op_array->fn_flags & ZEND_ACC_VARIADIC) != 0)) {
first_extra_arg--;
}
num_args = EX(num_args);
num_args = EX_NUM_ARGS();
if (UNEXPECTED(num_args > first_extra_arg)) {
zval *end, *src, *dst;
@ -1554,9 +1552,6 @@ static zend_always_inline void i_init_code_execute_data(zend_execute_data *execu
EX(opline) = op_array->opcodes;
EX(call) = NULL;
EX(return_value) = return_value;
EX(scope) = EG(scope);
EX(delayed_exception) = NULL;
EX(silence_op_num) = -1;
zend_attach_symbol_table(execute_data);
@ -1581,9 +1576,6 @@ static zend_always_inline void i_init_execute_data(zend_execute_data *execute_da
EX(opline) = op_array->opcodes;
EX(call) = NULL;
EX(return_value) = return_value;
EX(scope) = EG(scope);
EX(delayed_exception) = NULL;
EX(silence_op_num) = -1;
if (UNEXPECTED(EX(symbol_table) != NULL)) {
zend_attach_symbol_table(execute_data);
@ -1595,7 +1587,7 @@ static zend_always_inline void i_init_execute_data(zend_execute_data *execute_da
if (UNEXPECTED((op_array->fn_flags & ZEND_ACC_VARIADIC) != 0)) {
first_extra_arg--;
}
num_args = EX(num_args);
num_args = EX_NUM_ARGS();
if (UNEXPECTED(num_args > first_extra_arg)) {
zval *end, *src, *dst;
@ -1663,7 +1655,7 @@ ZEND_API zend_execute_data *zend_create_generator_execute_data(zend_execute_data
* restore it simply by replacing a pointer.
*/
zend_execute_data *execute_data;
uint32_t num_args = call->num_args;
uint32_t num_args = ZEND_CALL_NUM_ARGS(call);
size_t stack_size = (ZEND_CALL_FRAME_SLOT + MAX(op_array->last_var + op_array->T, num_args)) * sizeof(zval);
EG(vm_stack) = zend_vm_stack_new_page(
@ -1675,13 +1667,13 @@ ZEND_API zend_execute_data *zend_create_generator_execute_data(zend_execute_data
EG(vm_stack_end) = EG(vm_stack)->end;
execute_data = zend_vm_stack_push_call_frame(
VM_FRAME_TOP_FUNCTION,
ZEND_CALL_TOP_FUNCTION,
(zend_function*)op_array,
num_args,
call->called_scope,
Z_OBJ(call->This),
NULL TSRMLS_CC);
EX(num_args) = num_args;
EX_NUM_ARGS() = num_args;
/* copy arguments */
if (num_args > 0) {
@ -1695,7 +1687,6 @@ ZEND_API zend_execute_data *zend_create_generator_execute_data(zend_execute_data
}
EX(symbol_table) = NULL;
EX(scope) = EG(scope);
i_init_func_execute_data(execute_data, op_array, return_value TSRMLS_CC);

View file

@ -51,18 +51,6 @@ ZEND_API int zend_eval_stringl_ex(char *str, size_t str_len, zval *retval_ptr, c
ZEND_API char * zend_verify_arg_class_kind(const zend_arg_info *cur_arg_info, char **class_name, zend_class_entry **pce TSRMLS_DC);
ZEND_API void zend_verify_arg_error(int error_type, const zend_function *zf, uint32_t arg_num, const char *need_msg, const char *need_kind, const char *given_msg, const char *given_kind, zval *arg TSRMLS_DC);
static zend_always_inline void i_zval_ptr_dtor(zval *zval_ptr ZEND_FILE_LINE_DC TSRMLS_DC)
{
if (Z_REFCOUNTED_P(zval_ptr)) {
if (!Z_DELREF_P(zval_ptr)) {
ZEND_ASSERT(zval_ptr != &EG(uninitialized_zval));
_zval_dtor_func_for_ptr(Z_COUNTED_P(zval_ptr) ZEND_FILE_LINE_RELAY_CC);
} else {
GC_ZVAL_CHECK_POSSIBLE_ROOT(zval_ptr);
}
}
}
static zend_always_inline int i_zend_is_true(zval *op TSRMLS_DC)
{
int result;
@ -129,6 +117,65 @@ again:
return result;
}
static zend_always_inline zval* zend_assign_to_variable(zval *variable_ptr, zval *value, zend_uchar value_type TSRMLS_DC)
{
do {
if (UNEXPECTED(Z_REFCOUNTED_P(variable_ptr))) {
zend_refcounted *garbage;
if (Z_ISREF_P(variable_ptr)) {
variable_ptr = Z_REFVAL_P(variable_ptr);
if (EXPECTED(!Z_REFCOUNTED_P(variable_ptr))) {
break;
}
}
if (Z_TYPE_P(variable_ptr) == IS_OBJECT &&
UNEXPECTED(Z_OBJ_HANDLER_P(variable_ptr, set) != NULL)) {
Z_OBJ_HANDLER_P(variable_ptr, set)(variable_ptr, value TSRMLS_CC);
return variable_ptr;
}
if ((value_type & (IS_VAR|IS_CV)) && variable_ptr == value) {
return variable_ptr;
}
garbage = Z_COUNTED_P(variable_ptr);
if (--GC_REFCOUNT(garbage) == 0) {
ZVAL_COPY_VALUE(variable_ptr, value);
if (value_type == IS_CONST) {
/* IS_CONST can't be IS_OBJECT, IS_RESOURCE or IS_REFERENCE */
if (UNEXPECTED(Z_OPT_COPYABLE_P(variable_ptr))) {
zval_copy_ctor_func(variable_ptr);
}
} else if (value_type != IS_TMP_VAR) {
if (UNEXPECTED(Z_OPT_REFCOUNTED_P(variable_ptr))) {
Z_ADDREF_P(variable_ptr);
}
}
_zval_dtor_func_for_ptr(garbage ZEND_FILE_LINE_CC);
return variable_ptr;
} else { /* we need to split */
/* optimized version of GC_ZVAL_CHECK_POSSIBLE_ROOT(variable_ptr) */
if ((Z_COLLECTABLE_P(variable_ptr)) &&
UNEXPECTED(!GC_INFO(garbage))) {
gc_possible_root(garbage TSRMLS_CC);
}
}
}
} while (0);
ZVAL_COPY_VALUE(variable_ptr, value);
if (value_type == IS_CONST) {
/* IS_CONST can't be IS_OBJECT, IS_RESOURCE or IS_REFERENCE */
if (UNEXPECTED(Z_OPT_COPYABLE_P(variable_ptr))) {
zval_copy_ctor_func(variable_ptr);
}
} else if (value_type != IS_TMP_VAR) {
if (UNEXPECTED(Z_OPT_REFCOUNTED_P(variable_ptr))) {
Z_ADDREF_P(variable_ptr);
}
}
return variable_ptr;
}
ZEND_API int zval_update_constant(zval *pp, zend_bool inline_change TSRMLS_DC);
ZEND_API int zval_update_constant_inline_change(zval *pp, zend_class_entry *scope TSRMLS_DC);
ZEND_API int zval_update_constant_no_inline_change(zval *pp, zend_class_entry *scope TSRMLS_DC);
@ -162,7 +209,7 @@ static zend_always_inline zval* zend_vm_stack_alloc(size_t size TSRMLS_DC)
return (zval*)top;
}
static zend_always_inline zend_execute_data *zend_vm_stack_push_call_frame(uint32_t frame_info, zend_function *func, uint32_t num_args, zend_class_entry *called_scope, zend_object *object, zend_execute_data *prev TSRMLS_DC)
static zend_always_inline zend_execute_data *zend_vm_stack_push_call_frame(uint32_t call_info, zend_function *func, uint32_t num_args, zend_class_entry *called_scope, zend_object *object, zend_execute_data *prev TSRMLS_DC)
{
uint32_t used_stack = ZEND_CALL_FRAME_SLOT + num_args;
zend_execute_data *call;
@ -172,11 +219,11 @@ static zend_always_inline zend_execute_data *zend_vm_stack_push_call_frame(uint3
}
call = (zend_execute_data*)zend_vm_stack_alloc(used_stack * sizeof(zval) TSRMLS_CC);
call->func = func;
ZVAL_OBJ(&call->This, object);
Z_OBJ(call->This) = object;
ZEND_SET_CALL_INFO(call, call_info);
ZEND_CALL_NUM_ARGS(call) = 0;
call->called_scope = called_scope;
call->prev_execute_data = prev;
call->frame_info = frame_info;
call->num_args = 0;
return call;
}
@ -184,9 +231,9 @@ static zend_always_inline void zend_vm_stack_free_extra_args(zend_execute_data *
{
uint32_t first_extra_arg = call->func->op_array.num_args - ((call->func->common.fn_flags & ZEND_ACC_VARIADIC) != 0);
if (UNEXPECTED(call->num_args > first_extra_arg)) {
zval *end = EX_VAR_NUM_2(call, call->func->op_array.last_var + call->func->op_array.T);
zval *p = end + (call->num_args - first_extra_arg);
if (UNEXPECTED(ZEND_CALL_NUM_ARGS(call) > first_extra_arg)) {
zval *end = ZEND_CALL_VAR_NUM(call, call->func->op_array.last_var + call->func->op_array.T);
zval *p = end + (ZEND_CALL_NUM_ARGS(call) - first_extra_arg);
do {
p--;
zval_ptr_dtor_nogc(p);
@ -196,7 +243,7 @@ static zend_always_inline void zend_vm_stack_free_extra_args(zend_execute_data *
static zend_always_inline void zend_vm_stack_free_args(zend_execute_data *call TSRMLS_DC)
{
uint32_t num_args = call->num_args;
uint32_t num_args = ZEND_CALL_NUM_ARGS(call);
if (num_args > 0) {
zval *end = ZEND_CALL_ARG(call, 1);
@ -261,10 +308,7 @@ ZEND_API int zend_set_user_opcode_handler(zend_uchar opcode, user_opcode_handler
ZEND_API user_opcode_handler_t zend_get_user_opcode_handler(zend_uchar opcode);
/* former zend_execute_locks.h */
typedef struct _zend_free_op {
zval *var;
/* int is_var; */
} zend_free_op;
typedef zval* zend_free_op;
ZEND_API zval *zend_get_zval_ptr(int op_type, const znode_op *node, const zend_execute_data *execute_data, zend_free_op *should_free, int type TSRMLS_DC);

View file

@ -51,8 +51,8 @@ static WNDCLASS wc;
static HWND timeout_window;
static HANDLE timeout_thread_event;
static HANDLE timeout_thread_handle;
static DWORD timeout_thread_id;
static int timeout_thread_initialized=0;
static unsigned timeout_thread_id;
static volatile long timeout_thread_initialized=0;
#endif
#if 0&&ZEND_DEBUG
@ -736,7 +736,7 @@ int zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache TS
}
func = fci_cache->function_handler;
call = zend_vm_stack_push_call_frame(VM_FRAME_TOP_FUNCTION,
call = zend_vm_stack_push_call_frame(ZEND_CALL_TOP_FUNCTION,
func, fci->param_count, fci_cache->called_scope, fci_cache->object, NULL TSRMLS_CC);
calling_scope = fci_cache->calling_scope;
fci->object = fci_cache->object;
@ -787,7 +787,7 @@ int zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache TS
!ARG_MAY_BE_SENT_BY_REF(func, i + 1)) {
if (i) {
/* hack to clean up the stack */
call->num_args = i;
ZEND_CALL_NUM_ARGS(call) = i;
zend_vm_stack_free_args(call TSRMLS_CC);
}
zend_vm_stack_free_call_frame(call TSRMLS_CC);
@ -827,7 +827,7 @@ int zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache TS
ZVAL_COPY(param, &fci->params[i]);
}
}
call->num_args = fci->param_count;
ZEND_CALL_NUM_ARGS(call) = fci->param_count;
EG(scope) = calling_scope;
if (func->common.fn_flags & ZEND_ACC_STATIC) {
@ -835,9 +835,8 @@ int zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache TS
}
if (!fci->object) {
Z_OBJ(call->This) = NULL;
Z_TYPE_INFO(call->This) = IS_UNDEF;
} else {
ZVAL_OBJ(&call->This, fci->object);
Z_OBJ(call->This) = fci->object;
GC_REFCOUNT(fci->object)++;
}
@ -1166,6 +1165,10 @@ ZEND_API void zend_timeout(int dummy) /* {{{ */
#ifdef ZEND_WIN32
static LRESULT CALLBACK zend_timeout_WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) /* {{{ */
{
#ifdef ZTS
THREAD_T thread_id = (THREAD_T)wParam;
#endif
switch (message) {
case WM_DESTROY:
PostQuitMessage(0);
@ -1180,7 +1183,7 @@ static LRESULT CALLBACK zend_timeout_WndProc(HWND hWnd, UINT message, WPARAM wPa
#endif
SetTimer(timeout_window, wParam, lParam*1000, NULL);
#ifdef ZTS
tsrm_ls = ts_resource_ex(0, &wParam);
tsrm_ls = ts_resource_ex(0, &thread_id);
if (!tsrm_ls) {
/* shouldn't normally happen */
break;
@ -1197,7 +1200,7 @@ static LRESULT CALLBACK zend_timeout_WndProc(HWND hWnd, UINT message, WPARAM wPa
#ifdef ZTS
void ***tsrm_ls;
tsrm_ls = ts_resource_ex(0, &wParam);
tsrm_ls = ts_resource_ex(0, &thread_id);
if (!tsrm_ls) {
/* Thread died before receiving its timeout? */
break;
@ -1529,7 +1532,7 @@ ZEND_API zend_array *zend_rebuild_symbol_table(TSRMLS_D) /* {{{ */
for (i = 0; i < ex->func->op_array.last_var; i++) {
zval zv;
ZVAL_INDIRECT(&zv, EX_VAR_NUM_2(ex, i));
ZVAL_INDIRECT(&zv, ZEND_CALL_VAR_NUM(ex, i));
zend_hash_add_new(&symbol_table->ht,
ex->func->op_array.vars[i], &zv);
}

View file

@ -21,6 +21,8 @@
#ifndef ZEND_FLOAT_H
#define ZEND_FLOAT_H
BEGIN_EXTERN_C()
/*
Define functions for FP initialization and de-initialization.
*/
@ -28,6 +30,8 @@ extern ZEND_API void zend_init_fpu(TSRMLS_D);
extern ZEND_API void zend_shutdown_fpu(TSRMLS_D);
extern ZEND_API void zend_ensure_fpu_mode(TSRMLS_D);
END_EXTERN_C()
/* Copy of the contents of xpfpa.h (which is under public domain)
See http://wiki.php.net/rfc/rounding for details.
@ -53,7 +57,7 @@ extern ZEND_API void zend_ensure_fpu_mode(TSRMLS_D);
Implementation notes:
x86_64:
- Since all x86_64 compilers use SSE by default, it is probably unecessary
- Since all x86_64 compilers use SSE by default, it is probably unnecessary
to use these macros there. We define them anyway since we are too lazy
to differentiate the architecture. Also, the compiler option -mfpmath=i387
justifies this decision.

View file

@ -469,7 +469,7 @@ tail_call:
ht = NULL;
GC_SET_BLACK(GC_INFO(ref));
/* don't count references for compatibilty ??? */
/* don't count references for compatibility ??? */
if (GC_TYPE(ref) != IS_REFERENCE) {
count++;
}
@ -515,7 +515,7 @@ tail_call:
ZVAL_OBJ(&tmp, obj);
props = get_gc(&tmp, &table, &n TSRMLS_CC);
while (n > 0 && !Z_REFCOUNTED(table[n-1])) {
/* count non-refcounted for compatibilty ??? */
/* count non-refcounted for compatibility ??? */
if (Z_TYPE(table[n-1]) != IS_UNDEF) {
count++;
}
@ -532,7 +532,7 @@ tail_call:
} else {
count += gc_collect_white(ref TSRMLS_CC);
}
/* count non-refcounted for compatibilty ??? */
/* count non-refcounted for compatibility ??? */
} else if (Z_TYPE(table[i]) != IS_UNDEF) {
count++;
}
@ -563,7 +563,7 @@ tail_call:
for (idx = 0; idx < ht->nNumUsed; idx++) {
p = ht->arData + idx;
if (!Z_REFCOUNTED(p->val)) {
/* count non-refcounted for compatibilty ??? */
/* count non-refcounted for compatibility ??? */
if (Z_TYPE(p->val) != IS_UNDEF && Z_TYPE(p->val) != IS_INDIRECT) {
count++;
}
@ -641,7 +641,7 @@ static int gc_collect_roots(TSRMLS_D)
static void gc_remove_nested_data_from_buffer(zend_refcounted *ref TSRMLS_DC)
{
HashTable *ht;
HashTable *ht = NULL;
uint idx;
Bucket *p;

View file

@ -58,7 +58,7 @@ static void zend_generator_cleanup_unfinished_execution(zend_generator *generato
zend_op *brk_opline = op_array->opcodes + brk_cont->brk;
if (brk_opline->opcode == ZEND_FREE) {
zval *var = EX_VAR_2(execute_data, brk_opline->op1.var);
zval *var = EX_VAR(brk_opline->op1.var);
zval_ptr_dtor_nogc(var);
}
}
@ -133,7 +133,7 @@ static void zend_generator_dtor_storage(zend_object *object TSRMLS_DC) /* {{{ */
{
zend_generator *generator = (zend_generator*) object;
zend_execute_data *ex = generator->execute_data;
uint32_t op_num, finally_op_num;
uint32_t op_num, finally_op_num, finally_op_end;
int i;
if (!ex || !(ex->func->op_array.fn_flags & ZEND_ACC_HAS_FINALLY_BLOCK)) {
@ -146,6 +146,7 @@ static void zend_generator_dtor_storage(zend_object *object TSRMLS_DC) /* {{{ */
/* Find next finally block */
finally_op_num = 0;
finally_op_end = 0;
for (i = 0; i < ex->func->op_array.last_try_catch; i++) {
zend_try_catch_element *try_catch = &ex->func->op_array.try_catch_array[i];
@ -155,14 +156,17 @@ static void zend_generator_dtor_storage(zend_object *object TSRMLS_DC) /* {{{ */
if (op_num < try_catch->finally_op) {
finally_op_num = try_catch->finally_op;
finally_op_end = try_catch->finally_end;
}
}
/* If a finally block was found we jump directly to it and
* resume the generator. */
if (finally_op_num) {
zval *fast_call = ZEND_CALL_VAR(ex, ex->func->op_array.opcodes[finally_op_end].op1.var);
fast_call->u2.lineno = (uint32_t)-1;
ex->opline = &ex->func->op_array.opcodes[finally_op_num];
ex->fast_ret = NULL;
generator->flags |= ZEND_GENERATOR_FORCED_CLOSE;
zend_generator_resume(generator TSRMLS_CC);
}
@ -302,7 +306,7 @@ ZEND_API void zend_generator_resume(zend_generator *generator TSRMLS_DC) /* {{{
original_stack->top = EG(vm_stack_top);
/* Set executor globals */
EG(current_execute_data) = generator->execute_data;
EG(scope) = generator->execute_data->scope;
EG(scope) = generator->execute_data->func->common.scope;
EG(vm_stack_top) = generator->stack->top;
EG(vm_stack_end) = generator->stack->end;
EG(vm_stack) = generator->stack;

View file

@ -21,6 +21,7 @@
#include "zend.h"
#include "zend_globals.h"
#include "zend_variables.h"
#if ZEND_DEBUG
/*
@ -944,24 +945,115 @@ ZEND_API void zend_hash_destroy(HashTable *ht)
pefree(ht->arData, ht->u.flags & HASH_FLAG_PERSISTENT);
}
ZEND_API void zend_hash_clean(HashTable *ht)
ZEND_API void zend_array_destroy(HashTable *ht TSRMLS_DC)
{
uint32_t idx;
Bucket *p;
Bucket *p, *end;
IS_CONSISTENT(ht);
for (idx = 0; idx < ht->nNumUsed; idx++) {
p = ht->arData + idx;
if (Z_TYPE(p->val) == IS_UNDEF) continue;
if (ht->nNumUsed) {
/* In some rare cases destructors of regular arrays may be changed */
if (UNEXPECTED(ht->pDestructor != ZVAL_PTR_DTOR)) {
zend_hash_destroy(ht);
return;
}
p = ht->arData;
end = p + ht->nNumUsed;
SET_INCONSISTENT(HT_IS_DESTROYING);
if (ht->u.flags & HASH_FLAG_PACKED) {
do {
if (EXPECTED(Z_TYPE(p->val) != IS_UNDEF)) {
i_zval_ptr_dtor(&p->val ZEND_FILE_LINE_CC TSRMLS_CC);
}
} while (++p != end);
} else {
do {
if (EXPECTED(Z_TYPE(p->val) != IS_UNDEF)) {
i_zval_ptr_dtor(&p->val ZEND_FILE_LINE_CC TSRMLS_CC);
if (EXPECTED(p->key)) {
zend_string_release(p->key);
}
}
} while (++p != end);
}
SET_INCONSISTENT(HT_DESTROYED);
} else if (EXPECTED(!ht->nTableMask)) {
return;
}
pefree(ht->arData, ht->u.flags & HASH_FLAG_PERSISTENT);
}
ZEND_API void zend_hash_clean(HashTable *ht)
{
Bucket *p, *end;
IS_CONSISTENT(ht);
if (ht->nNumUsed) {
p = ht->arData;
end = p + ht->nNumUsed;
if (ht->pDestructor) {
ht->pDestructor(&p->val);
if (ht->u.flags & HASH_FLAG_PACKED) {
do {
if (EXPECTED(Z_TYPE(p->val) != IS_UNDEF)) {
ht->pDestructor(&p->val);
}
} while (++p != end);
} else {
do {
if (EXPECTED(Z_TYPE(p->val) != IS_UNDEF)) {
ht->pDestructor(&p->val);
if (EXPECTED(p->key)) {
zend_string_release(p->key);
}
}
} while (++p != end);
}
} else {
if (!(ht->u.flags & HASH_FLAG_PACKED)) {
do {
if (EXPECTED(Z_TYPE(p->val) != IS_UNDEF)) {
if (EXPECTED(p->key)) {
zend_string_release(p->key);
}
}
} while (++p != end);
}
}
if (p->key) {
zend_string_release(p->key);
}
ht->nNumUsed = 0;
ht->nNumOfElements = 0;
ht->nNextFreeElement = 0;
ht->nInternalPointer = INVALID_IDX;
if (ht->nTableMask) {
if (!(ht->u.flags & HASH_FLAG_PACKED)) {
memset(ht->arHash, INVALID_IDX, ht->nTableSize * sizeof(uint32_t));
}
}
}
ZEND_API void zend_symtable_clean(HashTable *ht TSRMLS_DC)
{
Bucket *p, *end;
IS_CONSISTENT(ht);
if (ht->nNumUsed) {
p = ht->arData;
end = p + ht->nNumUsed;
do {
if (EXPECTED(Z_TYPE(p->val) != IS_UNDEF)) {
i_zval_ptr_dtor(&p->val ZEND_FILE_LINE_CC TSRMLS_CC);
if (EXPECTED(p->key)) {
zend_string_release(p->key);
}
}
} while (++p != end);
}
ht->nNumUsed = 0;
ht->nNumOfElements = 0;
ht->nNextFreeElement = 0;
@ -1697,8 +1789,7 @@ ZEND_API int zend_hash_sort(HashTable *ht, sort_func_t sort_func,
p->key = NULL;
}
}
}
if (renumber) {
ht->nNextFreeElement = i;
}
if (ht->u.flags & HASH_FLAG_PACKED) {

View file

@ -216,6 +216,8 @@ ZEND_API zval *zend_hash_minmax(const HashTable *ht, compare_func_t compar, uint
ZEND_API int zend_hash_rehash(HashTable *ht);
ZEND_API void zend_array_dup(HashTable *target, HashTable *source);
ZEND_API void zend_array_destroy(HashTable *ht TSRMLS_DC);
ZEND_API void zend_symtable_clean(HashTable *ht TSRMLS_DC);
#if ZEND_DEBUG
/* debug */

View file

@ -31,7 +31,7 @@
#define zendleng LANG_SCNG(yy_leng)
static void handle_whitespace(int *emit_whitespace)
static void handle_whitespace(unsigned int *emit_whitespace)
{
unsigned char c;
int i;

View file

@ -1206,7 +1206,7 @@ static void zend_traits_init_trait_structures(zend_class_entry *ce TSRMLS_DC) /*
}
zend_check_trait_usage(ce, cur_precedence->trait_method->ce TSRMLS_CC);
/** Ensure that the prefered method is actually available. */
/** Ensure that the preferred method is actually available. */
lcname = zend_string_alloc(cur_method_ref->method_name->len, 0);
zend_str_tolower_copy(lcname->val,
cur_method_ref->method_name->val,
@ -1238,7 +1238,7 @@ static void zend_traits_init_trait_structures(zend_class_entry *ce TSRMLS_DC) /*
/* make sure that the trait method is not from a class mentioned in
exclude_from_classes, for consistency */
if (cur_precedence->trait_method->ce == cur_precedence->exclude_from_classes[i].ce) {
if (cur_precedence->trait_method->ce == cur_precedence->exclude_from_classes[j].ce) {
zend_error_noreturn(E_COMPILE_ERROR,
"Inconsistent insteadof definition. "
"The method %s is to be used from %s, but %s is also on the exclude list",
@ -1507,7 +1507,7 @@ static void zend_do_check_for_inconsistent_traits_aliasing(zend_class_entry *ce
lc_method_name)) {
zend_string_free(lc_method_name);
zend_error_noreturn(E_COMPILE_ERROR,
"The modifiers for the trait alias %s() need to be changed in the same statment in which the alias is defined. Error",
"The modifiers for the trait alias %s() need to be changed in the same statement in which the alias is defined. Error",
cur_alias->trait_method->method_name->val);
} else {
zend_string_free(lc_method_name);

View file

@ -184,7 +184,7 @@ static void zend_std_call_getter(zval *object, zval *member, zval *retval TSRMLS
/* __get handler is called with one argument:
property name
it should return whether the call was successfull or not
it should return whether the call was successful or not
*/
if (Z_REFCOUNTED_P(member)) Z_ADDREF_P(member);
@ -207,7 +207,7 @@ static int zend_std_call_setter(zval *object, zval *member, zval *value TSRMLS_D
property name
value to be set
it should return whether the call was successfull or not
it should return whether the call was successful or not
*/
zend_call_method_with_2_params(object, ce, &ce->__set, ZEND_SET_FUNC_NAME, &retval, member, value);
@ -545,51 +545,7 @@ ZEND_API void zend_std_write_property(zval *object, zval *member, zval *value, v
} else if (EXPECTED(zobj->properties != NULL)) {
if ((variable_ptr = zend_hash_find(zobj->properties, Z_STR_P(member))) != NULL) {
found:
/* if we already have this value there, we don't actually need to do anything */
if (EXPECTED(variable_ptr != value)) {
/* if we are assigning reference, we shouldn't move it, but instead assign variable
to the same pointer */
if (Z_ISREF_P(variable_ptr)) {
zval garbage;
ZVAL_COPY_VALUE(&garbage, Z_REFVAL_P(variable_ptr)); /* old value should be destroyed */
/* To check: can't *variable_ptr be some system variable like error_zval here? */
if (UNEXPECTED(Z_REFCOUNTED_P(value))) {
if (EXPECTED(!Z_ISREF_P(value))) {
Z_ADDREF_P(value);
} else {
if (Z_REFCOUNT_P(value) == 1) {
ZVAL_UNREF(value);
} else {
value = Z_REFVAL_P(value);
}
if (Z_REFCOUNTED_P(value)) {
if (UNEXPECTED(Z_REFVAL_P(variable_ptr) == value)) {
goto exit;
}
Z_ADDREF_P(value);
}
}
}
ZVAL_COPY_VALUE(Z_REFVAL_P(variable_ptr), value);
zval_ptr_dtor(&garbage);
} else {
zval garbage;
ZVAL_COPY_VALUE(&garbage, variable_ptr);
/* if we assign referenced variable, we should separate it */
ZVAL_COPY_VALUE(variable_ptr, value);
if (Z_REFCOUNTED_P(variable_ptr)) {
Z_ADDREF_P(variable_ptr);
if (Z_ISREF_P(variable_ptr)) {
SEPARATE_ZVAL(variable_ptr);
}
}
zval_ptr_dtor(&garbage);
}
}
zend_assign_to_variable(variable_ptr, value, (IS_VAR|IS_TMP_VAR) TSRMLS_CC);
goto exit;
}
}

View file

@ -47,18 +47,19 @@ ZEND_API void zend_object_std_init(zend_object *object, zend_class_entry *ce TSR
ZEND_API void zend_object_std_dtor(zend_object *object TSRMLS_DC)
{
int i;
int i, count;
if (object->guards) {
zend_hash_destroy(object->guards);
FREE_HASHTABLE(object->guards);
}
if (object->properties) {
zend_hash_destroy(object->properties);
zend_array_destroy(object->properties TSRMLS_CC);
FREE_HASHTABLE(object->properties);
}
for (i = 0; i < object->ce->default_properties_count; i++) {
zval_ptr_dtor(&object->properties_table[i]);
count = object->ce->default_properties_count;
for (i = 0; i < count; i++) {
i_zval_ptr_dtor(&object->properties_table[i] ZEND_FILE_LINE_CC TSRMLS_CC);
}
}

View file

@ -532,12 +532,19 @@ static void zend_resolve_finally_call(zend_op_array *op_array, uint32_t op_num,
(dst_num < op_array->try_catch_array[i].try_op ||
dst_num > op_array->try_catch_array[i].finally_end)) {
/* we have a jump out of try block that needs executing finally */
uint32_t fast_call_var;
/* Must be ZEND_FAST_RET */
ZEND_ASSERT(op_array->opcodes[op_array->try_catch_array[i].finally_end].opcode == ZEND_FAST_RET);
fast_call_var = op_array->opcodes[op_array->try_catch_array[i].finally_end].op1.var;
/* generate a FAST_CALL to finally block */
start_op = get_next_op_number(op_array);
opline = get_next_op(op_array TSRMLS_CC);
opline->opcode = ZEND_FAST_CALL;
opline->result_type = IS_TMP_VAR;
opline->result.var = fast_call_var;
SET_UNUSED(opline->op1);
SET_UNUSED(opline->op2);
zend_adjust_fast_call(op_array, start_op,
@ -550,6 +557,8 @@ static void zend_resolve_finally_call(zend_op_array *op_array, uint32_t op_num,
/* generate a FAST_CALL to hole CALL_FROM_FINALLY */
opline = get_next_op(op_array TSRMLS_CC);
opline->opcode = ZEND_FAST_CALL;
opline->result_type = IS_TMP_VAR;
opline->result.var = fast_call_var;
SET_UNUSED(opline->op1);
SET_UNUSED(opline->op2);
zend_resolve_fast_call(op_array, start_op + 1, op_array->try_catch_array[i].finally_op - 2 TSRMLS_CC);
@ -569,6 +578,8 @@ static void zend_resolve_finally_call(zend_op_array *op_array, uint32_t op_num,
opline = get_next_op(op_array TSRMLS_CC);
opline->opcode = ZEND_FAST_CALL;
opline->result_type = IS_TMP_VAR;
opline->result.var = fast_call_var;
SET_UNUSED(opline->op1);
SET_UNUSED(opline->op2);
opline->op1.opline_num = op_array->try_catch_array[i].finally_op;
@ -708,20 +719,20 @@ ZEND_API int pass_two(zend_op_array *op_array TSRMLS_DC)
if (opline->op1_type == IS_CONST) {
opline->op1.zv = &op_array->literals[opline->op1.constant];
} else if (opline->op1_type & (IS_VAR|IS_TMP_VAR)) {
opline->op1.var = (uint32_t)(zend_intptr_t)EX_VAR_NUM_2(NULL, op_array->last_var + opline->op1.var);
opline->op1.var = (uint32_t)(zend_intptr_t)ZEND_CALL_VAR_NUM(NULL, op_array->last_var + opline->op1.var);
}
if (opline->op2_type == IS_CONST) {
opline->op2.zv = &op_array->literals[opline->op2.constant];
} else if (opline->op2_type & (IS_VAR|IS_TMP_VAR)) {
opline->op2.var = (uint32_t)(zend_intptr_t)EX_VAR_NUM_2(NULL, op_array->last_var + opline->op2.var);
opline->op2.var = (uint32_t)(zend_intptr_t)ZEND_CALL_VAR_NUM(NULL, op_array->last_var + opline->op2.var);
}
if (opline->result_type & (IS_VAR|IS_TMP_VAR)) {
opline->result.var = (uint32_t)(zend_intptr_t)EX_VAR_NUM_2(NULL, op_array->last_var + opline->result.var);
opline->result.var = (uint32_t)(zend_intptr_t)ZEND_CALL_VAR_NUM(NULL, op_array->last_var + opline->result.var);
}
switch (opline->opcode) {
case ZEND_DECLARE_INHERITED_CLASS:
case ZEND_DECLARE_INHERITED_CLASS_DELAYED:
opline->extended_value = (uint32_t)(zend_intptr_t)EX_VAR_NUM_2(NULL, op_array->last_var + opline->extended_value);
opline->extended_value = (uint32_t)(zend_intptr_t)ZEND_CALL_VAR_NUM(NULL, op_array->last_var + opline->extended_value);
break;
case ZEND_GOTO:
if (Z_TYPE_P(opline->op2.zv) != IS_LONG) {

View file

@ -394,6 +394,13 @@ char *alloca();
#define ZEND_SECURE_ZERO(var, size) memset((var), 0, (size))
#endif
/* This check should only be used on network socket, not file descriptors */
#ifdef ZEND_WIN32
#define ZEND_VALID_SOCKET(sock) (INVALID_SOCKET != (sock))
#else
#define ZEND_VALID_SOCKET(sock) ((sock) >= 0)
#endif
#endif /* ZEND_PORTABILITY_H */
/*

View file

@ -112,7 +112,7 @@ struct _zval_struct {
zend_uchar type, /* active type */
zend_uchar type_flags,
zend_uchar const_flags,
zend_uchar reserved) /* various IS_VAR flags */
zend_uchar reserved) /* call info for EX(This) */
} v;
uint32_t type_info;
} u1;
@ -121,6 +121,7 @@ struct _zval_struct {
uint32_t next; /* hash collision chain */
uint32_t cache_slot; /* literal cache slot */
uint32_t lineno; /* line number (for ast nodes) */
uint32_t num_args; /* arguments number for EX(This) */
} u2;
};
@ -145,9 +146,9 @@ struct _zend_string {
};
typedef struct _Bucket {
zval val;
zend_ulong h; /* hash value (or numeric index) */
zend_string *key; /* string key or NULL for numerics */
zval val;
} Bucket;
typedef struct _HashTable {

View file

@ -45,7 +45,7 @@ ZEND_API void _zval_dtor_func(zend_refcounted *p ZEND_FILE_LINE_DC)
/* break possible cycles */
GC_TYPE(arr) = IS_NULL;
GC_REMOVE_FROM_BUFFER(arr);
zend_hash_destroy(&arr->ht);
zend_array_destroy(&arr->ht TSRMLS_CC);
efree_size(arr, sizeof(zend_array));
}
break;
@ -77,7 +77,9 @@ ZEND_API void _zval_dtor_func(zend_refcounted *p ZEND_FILE_LINE_DC)
case IS_REFERENCE: {
zend_reference *ref = (zend_reference*)p;
if (--GC_REFCOUNT(ref) == 0) {
zval_ptr_dtor(&ref->val);
TSRMLS_FETCH();
i_zval_ptr_dtor(&ref->val ZEND_FILE_LINE_RELAY_CC TSRMLS_CC);
efree_size(ref, sizeof(zend_reference));
}
break;
@ -105,7 +107,7 @@ ZEND_API void _zval_dtor_func_for_ptr(zend_refcounted *p ZEND_FILE_LINE_DC)
/* break possible cycles */
GC_TYPE(arr) = IS_NULL;
GC_REMOVE_FROM_BUFFER(arr);
zend_hash_destroy(&arr->ht);
zend_array_destroy(&arr->ht TSRMLS_CC);
efree_size(arr, sizeof(zend_array));
}
break;
@ -134,8 +136,9 @@ ZEND_API void _zval_dtor_func_for_ptr(zend_refcounted *p ZEND_FILE_LINE_DC)
}
case IS_REFERENCE: {
zend_reference *ref = (zend_reference*)p;
TSRMLS_FETCH();
zval_ptr_dtor(&ref->val);
i_zval_ptr_dtor(&ref->val ZEND_FILE_LINE_RELAY_CC TSRMLS_CC);
efree_size(ref, sizeof(zend_reference));
break;
}
@ -293,7 +296,9 @@ ZEND_API void _zval_internal_dtor_wrapper(zval *zvalue)
ZEND_API void _zval_ptr_dtor_wrapper(zval *zval_ptr)
{
zval_ptr_dtor(zval_ptr);
TSRMLS_FETCH();
i_zval_ptr_dtor(zval_ptr ZEND_FILE_LINE_CC TSRMLS_CC);
}

View file

@ -22,6 +22,8 @@
#ifndef ZEND_VARIABLES_H
#define ZEND_VARIABLES_H
#include "zend_types.h"
#include "zend_gc.h"
BEGIN_EXTERN_C()
@ -43,6 +45,17 @@ static zend_always_inline void _zval_ptr_dtor_nogc(zval *zval_ptr ZEND_FILE_LINE
}
}
static zend_always_inline void i_zval_ptr_dtor(zval *zval_ptr ZEND_FILE_LINE_DC TSRMLS_DC)
{
if (Z_REFCOUNTED_P(zval_ptr)) {
if (!Z_DELREF_P(zval_ptr)) {
_zval_dtor_func_for_ptr(Z_COUNTED_P(zval_ptr) ZEND_FILE_LINE_RELAY_CC);
} else {
GC_ZVAL_CHECK_POSSIBLE_ROOT(zval_ptr);
}
}
}
ZEND_API void _zval_copy_ctor_func(zval *zvalue ZEND_FILE_LINE_DC);
#define zval_copy_ctor_func(zv) _zval_copy_ctor_func(zv ZEND_FILE_LINE_CC)

View file

@ -347,7 +347,7 @@ CWD_API int php_sys_stat_ex(const char *path, zend_stat_t *buf, int lstat) /* {{
/* File is a reparse point. Get the target */
HANDLE hLink = NULL;
REPARSE_DATA_BUFFER * pbuffer;
unsigned int retlength = 0;
DWORD retlength = 0;
hLink = CreateFile(path, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_FLAG_OPEN_REPARSE_POINT|FILE_FLAG_BACKUP_SEMANTICS, NULL);
if(hLink == INVALID_HANDLE_VALUE) {
@ -898,7 +898,7 @@ static int tsrm_realpath_r(char *path, int start, int len, int *ll, time_t *t, i
/* File is a reparse point. Get the target */
HANDLE hLink = NULL;
REPARSE_DATA_BUFFER * pbuffer;
unsigned int retlength = 0;
DWORD retlength = 0;
int bufindex = 0, isabsolute = 0;
wchar_t * reparsetarget;
BOOL isVolume = FALSE;
@ -1540,55 +1540,6 @@ CWD_API int virtual_access(const char *pathname, int mode TSRMLS_DC) /* {{{ */
/* }}} */
#if HAVE_UTIME
#ifdef TSRM_WIN32
static void UnixTimeToFileTime(time_t t, LPFILETIME pft) /* {{{ */
{
// Note that LONGLONG is a 64-bit value
LONGLONG ll;
ll = Int32x32To64(t, 10000000) + 116444736000000000;
pft->dwLowDateTime = (DWORD)ll;
pft->dwHighDateTime = ll >> 32;
}
/* }}} */
TSRM_API int win32_utime(const char *filename, struct utimbuf *buf) /* {{{ */
{
FILETIME mtime, atime;
HANDLE hFile;
hFile = CreateFile(filename, GENERIC_WRITE, FILE_SHARE_WRITE|FILE_SHARE_READ, NULL,
OPEN_ALWAYS, FILE_FLAG_BACKUP_SEMANTICS, NULL);
/* OPEN_ALWAYS mode sets the last error to ERROR_ALREADY_EXISTS but
the CreateFile operation succeeds */
if (GetLastError() == ERROR_ALREADY_EXISTS) {
SetLastError(0);
}
if ( hFile == INVALID_HANDLE_VALUE ) {
return -1;
}
if (!buf) {
SYSTEMTIME st;
GetSystemTime(&st);
SystemTimeToFileTime(&st, &mtime);
atime = mtime;
} else {
UnixTimeToFileTime(buf->modtime, &mtime);
UnixTimeToFileTime(buf->actime, &atime);
}
if (!SetFileTime(hFile, NULL, &atime, &mtime)) {
CloseHandle(hFile);
return -1;
}
CloseHandle(hFile);
return 1;
}
/* }}} */
#endif
CWD_API int virtual_utime(const char *filename, struct utimbuf *buf TSRMLS_DC) /* {{{ */
{
cwd_state new_state;

View file

@ -21,9 +21,13 @@
#ifndef ZEND_VM_H
#define ZEND_VM_H
BEGIN_EXTERN_C()
ZEND_API void zend_vm_use_old_executor(void);
ZEND_API void zend_vm_set_opcode_handler(zend_op* opcode);
END_EXTERN_C()
#define ZEND_VM_SET_OPCODE_HANDLER(opline) zend_vm_set_opcode_handler(opline)
#endif

View file

@ -385,7 +385,7 @@ ZEND_VM_HELPER_EX(zend_binary_assign_op_obj_helper, VAR|UNUSED|CV, CONST|TMP|VAR
zval *value = Z_OBJ_HT_P(z)->get(z, &rv TSRMLS_CC);
if (Z_REFCOUNT_P(z) == 0) {
zval_dtor(z);
zend_objects_store_del(Z_OBJ_P(z) TSRMLS_CC);
}
ZVAL_COPY_VALUE(z, value);
}
@ -711,7 +711,7 @@ ZEND_VM_HELPER_EX(zend_pre_incdec_property_helper, VAR|UNUSED|CV, CONST|TMP|VAR|
zval *value = Z_OBJ_HT_P(z)->get(z, &rv TSRMLS_CC);
if (Z_REFCOUNT_P(z) == 0) {
zval_dtor(z);
zend_objects_store_del(Z_OBJ_P(z) TSRMLS_CC);
}
ZVAL_COPY_VALUE(z, value);
}
@ -798,7 +798,7 @@ ZEND_VM_HELPER_EX(zend_post_incdec_property_helper, VAR|UNUSED|CV, CONST|TMP|VAR
zval *value = Z_OBJ_HT_P(z)->get(z, &rv TSRMLS_CC);
if (Z_REFCOUNT_P(z) == 0) {
zval_dtor(z);
zend_objects_store_del(Z_OBJ_P(z) TSRMLS_CC);
}
ZVAL_COPY_VALUE(z, value);
}
@ -1199,7 +1199,7 @@ ZEND_VM_HANDLER(84, ZEND_FETCH_DIM_W, VAR|CV, CONST|TMP|VAR|UNUSED|CV)
ZVAL_DEREF(container);
zend_fetch_dimension_address_W(EX_VAR(opline->result.var), container, GET_OP2_ZVAL_PTR_DEREF(BP_VAR_R), OP2_TYPE TSRMLS_CC);
FREE_OP2();
if (OP1_TYPE == IS_VAR && READY_TO_DESTROY(free_op1.var)) {
if (OP1_TYPE == IS_VAR && READY_TO_DESTROY(free_op1)) {
EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var));
}
FREE_OP1_VAR_PTR();
@ -1222,7 +1222,7 @@ ZEND_VM_HANDLER(87, ZEND_FETCH_DIM_RW, VAR|CV, CONST|TMP|VAR|UNUSED|CV)
ZVAL_DEREF(container);
zend_fetch_dimension_address_RW(EX_VAR(opline->result.var), container, GET_OP2_ZVAL_PTR_DEREF(BP_VAR_R), OP2_TYPE TSRMLS_CC);
FREE_OP2();
if (OP1_TYPE == IS_VAR && READY_TO_DESTROY(free_op1.var)) {
if (OP1_TYPE == IS_VAR && READY_TO_DESTROY(free_op1)) {
EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var));
}
FREE_OP1_VAR_PTR();
@ -1263,7 +1263,7 @@ ZEND_VM_HANDLER(93, ZEND_FETCH_DIM_FUNC_ARG, CONST|TMP|VAR|CV, CONST|TMP|VAR|UNU
}
ZVAL_DEREF(container);
zend_fetch_dimension_address_W(EX_VAR(opline->result.var), container, GET_OP2_ZVAL_PTR_DEREF(BP_VAR_R), OP2_TYPE TSRMLS_CC);
if (OP1_TYPE == IS_VAR && READY_TO_DESTROY(free_op1.var)) {
if (OP1_TYPE == IS_VAR && READY_TO_DESTROY(free_op1)) {
EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var));
}
FREE_OP2();
@ -1296,7 +1296,7 @@ ZEND_VM_HANDLER(96, ZEND_FETCH_DIM_UNSET, VAR|CV, CONST|TMP|VAR|CV)
ZVAL_DEREF(container);
zend_fetch_dimension_address_UNSET(EX_VAR(opline->result.var), container, GET_OP2_ZVAL_PTR_DEREF(BP_VAR_R), OP2_TYPE TSRMLS_CC);
FREE_OP2();
if (OP1_TYPE == IS_VAR && READY_TO_DESTROY(free_op1.var)) {
if (OP1_TYPE == IS_VAR && READY_TO_DESTROY(free_op1)) {
EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var));
}
FREE_OP1_VAR_PTR();
@ -1326,7 +1326,7 @@ ZEND_VM_HANDLER(82, ZEND_FETCH_OBJ_R, CONST|TMP|VAR|UNUSED|CV, CONST|TMP|VAR|CV)
/* here we are sure we are dealing with an object */
do {
if (OP2_TYPE == IS_CONST &&
EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) {
EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) {
zend_property_info *prop_info = CACHED_PTR(Z_CACHE_SLOT_P(offset) + 1);
zend_object *zobj = Z_OBJ_P(container);
@ -1376,7 +1376,7 @@ ZEND_VM_HANDLER(85, ZEND_FETCH_OBJ_W, VAR|UNUSED|CV, CONST|TMP|VAR|CV)
zend_fetch_property_address(EX_VAR(opline->result.var), container, OP1_TYPE, property, OP2_TYPE, ((OP2_TYPE == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_W TSRMLS_CC);
FREE_OP2();
if (OP1_TYPE == IS_VAR && READY_TO_DESTROY(free_op1.var)) {
if (OP1_TYPE == IS_VAR && READY_TO_DESTROY(free_op1)) {
EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var));
}
FREE_OP1_VAR_PTR();
@ -1400,7 +1400,7 @@ ZEND_VM_HANDLER(88, ZEND_FETCH_OBJ_RW, VAR|UNUSED|CV, CONST|TMP|VAR|CV)
}
zend_fetch_property_address(EX_VAR(opline->result.var), container, OP1_TYPE, property, OP2_TYPE, ((OP2_TYPE == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_RW TSRMLS_CC);
FREE_OP2();
if (OP1_TYPE == IS_VAR && READY_TO_DESTROY(free_op1.var)) {
if (OP1_TYPE == IS_VAR && READY_TO_DESTROY(free_op1)) {
EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var));
}
FREE_OP1_VAR_PTR();
@ -1415,8 +1415,6 @@ ZEND_VM_HANDLER(91, ZEND_FETCH_OBJ_IS, CONST|TMP|VAR|UNUSED|CV, CONST|TMP|VAR|CV
zval *container;
zend_free_op free_op2;
zval *offset;
zval *retval;
zend_property_info *prop_info;
SAVE_OPLINE();
container = GET_OP1_OBJ_ZVAL_PTR_DEREF(BP_VAR_IS);
@ -1431,7 +1429,7 @@ ZEND_VM_HANDLER(91, ZEND_FETCH_OBJ_IS, CONST|TMP|VAR|UNUSED|CV, CONST|TMP|VAR|CV
/* here we are sure we are dealing with an object */
do {
if (OP2_TYPE == IS_CONST &&
EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) {
EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) {
zend_property_info *prop_info = CACHED_PTR(Z_CACHE_SLOT_P(offset) + 1);
zend_object *zobj = Z_OBJ_P(container);
@ -1486,7 +1484,7 @@ ZEND_VM_HANDLER(94, ZEND_FETCH_OBJ_FUNC_ARG, CONST|TMP|VAR|UNUSED|CV, CONST|TMP|
}
zend_fetch_property_address(EX_VAR(opline->result.var), container, OP1_TYPE, property, OP2_TYPE, ((OP2_TYPE == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_W TSRMLS_CC);
FREE_OP2();
if (OP1_TYPE == IS_VAR && READY_TO_DESTROY(free_op1.var)) {
if (OP1_TYPE == IS_VAR && READY_TO_DESTROY(free_op1)) {
EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var));
}
FREE_OP1_VAR_PTR();
@ -1512,7 +1510,7 @@ ZEND_VM_HANDLER(97, ZEND_FETCH_OBJ_UNSET, VAR|UNUSED|CV, CONST|TMP|VAR|CV)
}
zend_fetch_property_address(EX_VAR(opline->result.var), container, OP1_TYPE, property, OP2_TYPE, ((OP2_TYPE == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_UNSET TSRMLS_CC);
FREE_OP2();
if (OP1_TYPE == IS_VAR && READY_TO_DESTROY(free_op1.var)) {
if (OP1_TYPE == IS_VAR && READY_TO_DESTROY(free_op1)) {
EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var));
}
FREE_OP1_VAR_PTR();
@ -1738,9 +1736,9 @@ ZEND_VM_HANDLER(39, ZEND_ASSIGN_REF, VAR|CV, VAR|CV)
ZEND_VM_HELPER(zend_leave_helper, ANY, ANY)
{
vm_frame_kind frame_kind = VM_FRAME_KIND(EX(frame_info));
zend_call_kind call_kind = EX_CALL_KIND();
if (frame_kind == VM_FRAME_NESTED_FUNCTION) {
if (call_kind == ZEND_CALL_NESTED_FUNCTION) {
zend_object *object;
i_free_compiled_variables(execute_data TSRMLS_CC);
@ -1768,7 +1766,7 @@ ZEND_VM_HELPER(zend_leave_helper, ANY, ANY)
}
OBJ_RELEASE(object);
}
EG(scope) = EX(scope);
EG(scope) = EX(func)->op_array.scope;
if (UNEXPECTED(EG(exception) != NULL)) {
const zend_op *opline = EX(opline);
@ -1782,7 +1780,7 @@ ZEND_VM_HELPER(zend_leave_helper, ANY, ANY)
LOAD_OPLINE();
ZEND_VM_INC_OPCODE();
ZEND_VM_LEAVE();
} else if (frame_kind == VM_FRAME_NESTED_CODE) {
} else if (call_kind == ZEND_CALL_NESTED_CODE) {
zend_detach_symbol_table(execute_data);
destroy_op_array(&EX(func)->op_array TSRMLS_CC);
efree_size(EX(func), sizeof(zend_op_array));
@ -1800,7 +1798,7 @@ ZEND_VM_HELPER(zend_leave_helper, ANY, ANY)
ZEND_VM_INC_OPCODE();
ZEND_VM_LEAVE();
} else {
if (frame_kind == VM_FRAME_TOP_FUNCTION) {
if (call_kind == ZEND_CALL_TOP_FUNCTION) {
i_free_compiled_variables(execute_data TSRMLS_CC);
if (UNEXPECTED(EX(symbol_table) != NULL)) {
zend_clean_and_cache_symbol_table(EX(symbol_table) TSRMLS_CC);
@ -1810,7 +1808,7 @@ ZEND_VM_HELPER(zend_leave_helper, ANY, ANY)
if ((EX(func)->op_array.fn_flags & ZEND_ACC_CLOSURE) && EX(func)->op_array.prototype) {
OBJ_RELEASE((zend_object*)EX(func)->op_array.prototype);
}
} else /* if (frame_kind == VM_FRAME_TOP_CODE) */ {
} else /* if (call_kind == ZEND_CALL_TOP_CODE) */ {
zend_array *symbol_table = EX(symbol_table);
zend_execute_data *old_execute_data;
@ -2070,7 +2068,9 @@ ZEND_VM_HANDLER(56, ZEND_ADD_VAR, TMP|UNUSED, TMP|VAR|CV)
}
if (Z_TYPE_P(var) != IS_STRING) {
ZVAL_DEREF(var);
if (OP2_TYPE != IS_TMP_VAR) {
ZVAL_DEREF(var);
}
if (Z_TYPE_P(var) != IS_STRING) {
use_copy = zend_make_printable_zval(var, &var_copy TSRMLS_CC);
@ -2082,7 +2082,7 @@ ZEND_VM_HANDLER(56, ZEND_ADD_VAR, TMP|UNUSED, TMP|VAR|CV)
add_string_to_string(str, str, var);
if (use_copy) {
zval_dtor(var);
zend_string_release(Z_STR_P(var));
}
/* original comment, possibly problematic:
* FREE_OP is missing intentionally here - we're always working on the same temporary variable
@ -2235,7 +2235,7 @@ ZEND_VM_HANDLER(112, ZEND_INIT_METHOD_CALL, TMP|VAR|UNUSED|CV, CONST|TMP|VAR|CV)
GC_REFCOUNT(obj)++; /* For $this pointer */
}
EX(call) = zend_vm_stack_push_call_frame(VM_FRAME_NESTED_FUNCTION,
EX(call) = zend_vm_stack_push_call_frame(ZEND_CALL_NESTED_FUNCTION,
fbc, opline->extended_value, called_scope, obj, EX(call) TSRMLS_CC);
FREE_OP2();
@ -2358,7 +2358,7 @@ ZEND_VM_HANDLER(113, ZEND_INIT_STATIC_METHOD_CALL, CONST|VAR, CONST|TMP|VAR|UNUS
}
}
EX(call) = zend_vm_stack_push_call_frame(VM_FRAME_NESTED_FUNCTION,
EX(call) = zend_vm_stack_push_call_frame(ZEND_CALL_NESTED_FUNCTION,
fbc, opline->extended_value, ce, object, EX(call) TSRMLS_CC);
if (OP2_TYPE == IS_UNUSED) {
@ -2387,7 +2387,7 @@ ZEND_VM_HANDLER(59, ZEND_INIT_FCALL_BY_NAME, ANY, CONST|TMP|VAR|CV)
CACHE_PTR(Z_CACHE_SLOT_P(opline->op2.zv), fbc);
}
EX(call) = zend_vm_stack_push_call_frame(VM_FRAME_NESTED_FUNCTION,
EX(call) = zend_vm_stack_push_call_frame(ZEND_CALL_NESTED_FUNCTION,
fbc, opline->extended_value, NULL, NULL, EX(call) TSRMLS_CC);
/*CHECK_EXCEPTION();*/
@ -2397,12 +2397,10 @@ ZEND_VM_HANDLER(59, ZEND_INIT_FCALL_BY_NAME, ANY, CONST|TMP|VAR|CV)
zend_free_op free_op2;
zend_class_entry *called_scope;
zend_object *object;
zval *function_name_ptr;
SAVE_OPLINE();
function_name_ptr = function_name = GET_OP2_ZVAL_PTR(BP_VAR_R);
function_name = GET_OP2_ZVAL_PTR_DEREF(BP_VAR_R);
ZVAL_DEREF(function_name);
if (EXPECTED(Z_TYPE_P(function_name) == IS_STRING)) {
if (Z_STRVAL_P(function_name)[0] == '\\') {
lcname = zend_string_alloc(Z_STRLEN_P(function_name) - 1, 0);
@ -2427,10 +2425,9 @@ ZEND_VM_HANDLER(59, ZEND_INIT_FCALL_BY_NAME, ANY, CONST|TMP|VAR|CV)
if (object) {
GC_REFCOUNT(object)++;
}
if (OP2_TYPE == IS_VAR && OP2_FREE && Z_REFCOUNT_P(function_name) == 1 &&
fbc->common.fn_flags & ZEND_ACC_CLOSURE) {
if (OP2_TYPE == IS_VAR && (fbc->common.fn_flags & ZEND_ACC_CLOSURE)) {
/* Delay closure destruction until its invocation */
fbc->common.prototype = (zend_function*)Z_OBJ_P(function_name_ptr);
fbc->common.prototype = (zend_function*)Z_OBJ_P(free_op2);
} else if (OP2_TYPE == IS_CV) {
FREE_OP2();
}
@ -2507,7 +2504,7 @@ ZEND_VM_HANDLER(59, ZEND_INIT_FCALL_BY_NAME, ANY, CONST|TMP|VAR|CV)
zend_error_noreturn(E_ERROR, "Function name must be a string");
ZEND_VM_CONTINUE(); /* Never reached */
}
EX(call) = zend_vm_stack_push_call_frame(VM_FRAME_NESTED_FUNCTION,
EX(call) = zend_vm_stack_push_call_frame(ZEND_CALL_NESTED_FUNCTION,
fbc, opline->extended_value, called_scope, object, EX(call) TSRMLS_CC);
CHECK_EXCEPTION();
@ -2561,7 +2558,7 @@ ZEND_VM_HANDLER(118, ZEND_INIT_USER_CALL, CONST, CONST|TMP|VAR|CV)
object = NULL;
}
EX(call) = zend_vm_stack_push_call_frame(VM_FRAME_NESTED_FUNCTION,
EX(call) = zend_vm_stack_push_call_frame(ZEND_CALL_NESTED_FUNCTION,
func, opline->extended_value, called_scope, object, EX(call) TSRMLS_CC);
FREE_OP2();
@ -2593,7 +2590,7 @@ ZEND_VM_HANDLER(69, ZEND_INIT_NS_FCALL_BY_NAME, ANY, CONST)
CACHE_PTR(Z_CACHE_SLOT_P(opline->op2.zv), fbc);
}
EX(call) = zend_vm_stack_push_call_frame(VM_FRAME_NESTED_FUNCTION,
EX(call) = zend_vm_stack_push_call_frame(ZEND_CALL_NESTED_FUNCTION,
fbc, opline->extended_value, NULL, NULL, EX(call) TSRMLS_CC);
ZEND_VM_NEXT_OPCODE();
@ -2617,7 +2614,7 @@ ZEND_VM_HANDLER(61, ZEND_INIT_FCALL, ANY, CONST)
CACHE_PTR(Z_CACHE_SLOT_P(fname), fbc);
}
EX(call) = zend_vm_stack_push_call_frame(VM_FRAME_NESTED_FUNCTION,
EX(call) = zend_vm_stack_push_call_frame(ZEND_CALL_NESTED_FUNCTION,
fbc, opline->extended_value, NULL, NULL, EX(call) TSRMLS_CC);
FREE_OP2();
@ -2676,8 +2673,8 @@ ZEND_VM_HANDLER(60, ZEND_DO_FCALL, ANY, ANY)
uint32_t i;
zval *p = ZEND_CALL_ARG(call, 1);
for (i = 0; i < call->num_args; ++i) {
zend_verify_arg_type(fbc, i + 1, p TSRMLS_CC);
for (i = 0; i < ZEND_CALL_NUM_ARGS(call); ++i) {
zend_verify_arg_type(fbc, i + 1, p, NULL TSRMLS_CC);
p++;
}
if (UNEXPECTED(EG(exception) != NULL)) {
@ -2719,7 +2716,7 @@ ZEND_VM_HANDLER(60, ZEND_DO_FCALL, ANY, ANY)
ZEND_VM_C_GOTO(fcall_end);
}
} else if (EXPECTED(fbc->type == ZEND_USER_FUNCTION)) {
call->scope = EG(scope) = fbc->common.scope;
EG(scope) = fbc->common.scope;
if (UNEXPECTED((fbc->common.fn_flags & ZEND_ACC_GENERATOR) != 0)) {
if (RETURN_VALUE_USED(opline)) {
zend_generator_create_zval(call, &fbc->op_array, EX_VAR(opline->result.var) TSRMLS_CC);
@ -2745,9 +2742,7 @@ ZEND_VM_HANDLER(60, ZEND_DO_FCALL, ANY, ANY)
if (EXPECTED(zend_execute_ex == execute_ex)) {
ZEND_VM_ENTER();
} else {
call->frame_info = VM_FRAME_INFO(
VM_FRAME_TOP_FUNCTION,
VM_FRAME_FLAGS(call->frame_info));
ZEND_ADD_CALL_FLAG(call, ZEND_CALL_TOP);
zend_execute_ex(call TSRMLS_CC);
}
}
@ -2796,7 +2791,7 @@ ZEND_VM_C_LABEL(fcall_end_change_scope):
}
OBJ_RELEASE(object);
}
EG(scope) = EX(scope);
EG(scope) = EX(func)->op_array.scope;
ZEND_VM_C_LABEL(fcall_end):
if (UNEXPECTED(EG(exception) != NULL)) {
@ -2982,9 +2977,7 @@ ZEND_VM_HANDLER(107, ZEND_CATCH, CONST, CV)
}
exception = EG(exception);
if (Z_REFCOUNTED_P(EX_VAR(opline->op2.var))) {
zval_ptr_dtor(EX_VAR(opline->op2.var));
}
zval_ptr_dtor(EX_VAR(opline->op2.var));
ZVAL_OBJ(EX_VAR(opline->op2.var), EG(exception));
if (UNEXPECTED(EG(exception) != exception)) {
GC_REFCOUNT(EG(exception))++;
@ -3004,7 +2997,7 @@ ZEND_VM_HANDLER(65, ZEND_SEND_VAL, CONST|TMP, ANY)
SAVE_OPLINE();
value = GET_OP1_ZVAL_PTR(BP_VAR_R);
arg = ZEND_CALL_ARG(EX(call), opline->op2.num);
EX(call)->num_args = opline->op2.num;
ZEND_CALL_NUM_ARGS(EX(call)) = opline->op2.num;
ZVAL_COPY_VALUE(arg, value);
if (OP1_TYPE == IS_CONST) {
if (UNEXPECTED(Z_OPT_COPYABLE_P(arg))) {
@ -3026,7 +3019,7 @@ ZEND_VM_HANDLER(116, ZEND_SEND_VAL_EX, CONST|TMP, ANY)
}
value = GET_OP1_ZVAL_PTR(BP_VAR_R);
arg = ZEND_CALL_ARG(EX(call), opline->op2.num);
EX(call)->num_args = opline->op2.num;
ZEND_CALL_NUM_ARGS(EX(call)) = opline->op2.num;
ZVAL_COPY_VALUE(arg, value);
if (OP1_TYPE == IS_CONST) {
if (UNEXPECTED(Z_OPT_COPYABLE_P(arg))) {
@ -3044,7 +3037,7 @@ ZEND_VM_HANDLER(117, ZEND_SEND_VAR, VAR|CV, ANY)
varptr = GET_OP1_ZVAL_PTR(BP_VAR_R);
arg = ZEND_CALL_ARG(EX(call), opline->op2.num);
EX(call)->num_args = opline->op2.num;
ZEND_CALL_NUM_ARGS(EX(call)) = opline->op2.num;
if ((OP1_TYPE == IS_CV || OP1_TYPE == IS_VAR) && Z_ISREF_P(varptr)) {
ZVAL_COPY(arg, Z_REFVAL_P(varptr));
FREE_OP1();
@ -3064,11 +3057,8 @@ ZEND_VM_HANDLER(106, ZEND_SEND_VAR_NO_REF, VAR|CV, ANY)
zval *varptr, *arg;
SAVE_OPLINE();
if (opline->extended_value & ZEND_ARG_COMPILE_TIME_BOUND) { /* Had function_ptr at compile_time */
if (!(opline->extended_value & ZEND_ARG_SEND_BY_REF)) {
ZEND_VM_DISPATCH_TO_HANDLER(ZEND_SEND_VAR);
}
} else {
if (!(opline->extended_value & ZEND_ARG_COMPILE_TIME_BOUND)) {
if (!ARG_SHOULD_BE_SENT_BY_REF(EX(call)->func, opline->op2.num)) {
ZEND_VM_DISPATCH_TO_HANDLER(ZEND_SEND_VAR);
}
@ -3083,20 +3073,18 @@ ZEND_VM_HANDLER(106, ZEND_SEND_VAR_NO_REF, VAR|CV, ANY)
if (OP1_TYPE == IS_CV) {
Z_ADDREF_P(varptr);
}
arg = ZEND_CALL_ARG(EX(call), opline->op2.num);
EX(call)->num_args = opline->op2.num;
ZVAL_COPY_VALUE(arg, varptr);
} else {
if ((opline->extended_value & ZEND_ARG_COMPILE_TIME_BOUND) ?
!(opline->extended_value & ZEND_ARG_SEND_SILENT) :
!ARG_MAY_BE_SENT_BY_REF(EX(call)->func, opline->op2.num)) {
zend_error(E_STRICT, "Only variables should be passed by reference");
}
arg = ZEND_CALL_ARG(EX(call), opline->op2.num);
EX(call)->num_args = opline->op2.num;
ZVAL_COPY(arg, varptr);
FREE_OP1_IF_VAR();
}
arg = ZEND_CALL_ARG(EX(call), opline->op2.num);
ZEND_CALL_NUM_ARGS(EX(call)) = opline->op2.num;
ZVAL_COPY_VALUE(arg, varptr);
CHECK_EXCEPTION();
ZEND_VM_NEXT_OPCODE();
}
@ -3115,7 +3103,7 @@ ZEND_VM_HANDLER(67, ZEND_SEND_REF, VAR|CV, ANY)
}
arg = ZEND_CALL_ARG(EX(call), opline->op2.num);
EX(call)->num_args = opline->op2.num;
ZEND_CALL_NUM_ARGS(EX(call)) = opline->op2.num;
if (OP1_TYPE == IS_VAR && UNEXPECTED(varptr == &EG(error_zval))) {
ZVAL_NEW_REF(arg, &EG(uninitialized_zval));
ZEND_VM_NEXT_OPCODE();
@ -3126,12 +3114,11 @@ ZEND_VM_HANDLER(67, ZEND_SEND_REF, VAR|CV, ANY)
ZVAL_COPY_VALUE(arg, varptr);
} else if (OP1_TYPE == IS_VAR &&
UNEXPECTED(Z_TYPE_P(EX_VAR(opline->op1.var)) != IS_INDIRECT)) {
ZVAL_COPY_VALUE(arg, varptr);
ZVAL_MAKE_REF(arg);
ZVAL_NEW_REF(arg, varptr);
} else {
ZVAL_MAKE_REF(varptr);
Z_ADDREF_P(varptr);
ZVAL_REF(arg, Z_REF_P(varptr));
ZVAL_NEW_REF(arg, varptr);
Z_ADDREF_P(arg);
ZVAL_REF(varptr, Z_REF_P(arg));
}
FREE_OP1_VAR_PTR();
@ -3149,7 +3136,7 @@ ZEND_VM_HANDLER(66, ZEND_SEND_VAR_EX, VAR|CV, ANY)
}
varptr = GET_OP1_ZVAL_PTR(BP_VAR_R);
arg = ZEND_CALL_ARG(EX(call), opline->op2.num);
EX(call)->num_args = opline->op2.num;
ZEND_CALL_NUM_ARGS(EX(call)) = opline->op2.num;
if ((OP1_TYPE == IS_CV || OP1_TYPE == IS_VAR) && Z_ISREF_P(varptr)) {
ZVAL_COPY(arg, Z_REFVAL_P(varptr));
FREE_OP1();
@ -3171,7 +3158,7 @@ ZEND_VM_HANDLER(165, ZEND_SEND_UNPACK, ANY, ANY)
SAVE_OPLINE();
args = GET_OP1_ZVAL_PTR(BP_VAR_R);
arg_num = EX(call)->num_args + 1;
arg_num = ZEND_CALL_NUM_ARGS(EX(call)) + 1;
ZEND_VM_C_LABEL(send_again):
switch (Z_TYPE_P(args)) {
@ -3222,7 +3209,7 @@ ZEND_VM_C_LABEL(send_again):
ZVAL_COPY(top, arg);
}
EX(call)->num_args++;
ZEND_CALL_NUM_ARGS(EX(call))++;
arg_num++;
} ZEND_HASH_FOREACH_END();
@ -3277,7 +3264,7 @@ ZEND_VM_C_LABEL(send_again):
if (Z_TYPE(key) == IS_STRING) {
zend_error(E_RECOVERABLE_ERROR,
"Cannot unpack Traversable with string keys");
zval_dtor(&key);
zend_string_release(Z_STR(key));
ZEND_VM_C_GOTO(unpack_iter_dtor);
}
@ -3303,7 +3290,7 @@ ZEND_VM_C_LABEL(send_again):
zend_vm_stack_extend_call_frame(&EX(call), arg_num - 1, 1 TSRMLS_CC);
top = ZEND_CALL_ARG(EX(call), arg_num);
ZVAL_COPY_VALUE(top, arg);
EX(call)->num_args++;
ZEND_CALL_NUM_ARGS(EX(call))++;
iter->funcs->move_forward(iter TSRMLS_CC);
if (UNEXPECTED(EG(exception) != NULL)) {
@ -3435,7 +3422,7 @@ ZEND_VM_HANDLER(119, ZEND_SEND_ARRAY, ANY, ANY)
} else {
ZVAL_COPY(param, arg);
}
EX(call)->num_args++;
ZEND_CALL_NUM_ARGS(EX(call))++;
arg_num++;
param++;
} ZEND_HASH_FOREACH_END();
@ -3517,7 +3504,7 @@ ZEND_VM_HANDLER(120, ZEND_SEND_USER, VAR|CV, ANY)
ZVAL_COPY(param, arg);
}
EX(call)->num_args = opline->op2.num;
ZEND_CALL_NUM_ARGS(EX(call)) = opline->op2.num;
FREE_OP1();
CHECK_EXCEPTION();
@ -3530,13 +3517,13 @@ ZEND_VM_HANDLER(63, ZEND_RECV, ANY, ANY)
uint32_t arg_num = opline->op1.num;
SAVE_OPLINE();
if (UNEXPECTED(arg_num > EX(num_args))) {
if (UNEXPECTED(arg_num > EX_NUM_ARGS())) {
zend_verify_missing_arg(execute_data, arg_num TSRMLS_CC);
CHECK_EXCEPTION();
} else if (UNEXPECTED((EX(func)->op_array.fn_flags & ZEND_ACC_HAS_TYPE_HINTS) != 0)) {
zval *param = _get_zval_ptr_cv_undef_BP_VAR_W(execute_data, opline->result.var TSRMLS_CC);
zend_verify_arg_type(EX(func), arg_num, param TSRMLS_CC);
zend_verify_arg_type(EX(func), arg_num, param, NULL TSRMLS_CC);
CHECK_EXCEPTION();
}
@ -3551,7 +3538,7 @@ ZEND_VM_HANDLER(64, ZEND_RECV_INIT, ANY, CONST)
SAVE_OPLINE();
param = _get_zval_ptr_cv_undef_BP_VAR_W(execute_data, opline->result.var TSRMLS_CC);
if (arg_num > EX(num_args)) {
if (arg_num > EX_NUM_ARGS()) {
ZVAL_COPY_VALUE(param, opline->op2.zv);
if (Z_OPT_CONSTANT_P(param)) {
zval_update_constant(param, 0 TSRMLS_CC);
@ -3564,7 +3551,7 @@ ZEND_VM_HANDLER(64, ZEND_RECV_INIT, ANY, CONST)
}
if (UNEXPECTED((EX(func)->op_array.fn_flags & ZEND_ACC_HAS_TYPE_HINTS) != 0)) {
zend_verify_arg_type(EX(func), arg_num, param TSRMLS_CC);
zend_verify_arg_type(EX(func), arg_num, param, opline->op2.zv TSRMLS_CC);
}
CHECK_EXCEPTION();
@ -3575,7 +3562,7 @@ ZEND_VM_HANDLER(164, ZEND_RECV_VARIADIC, ANY, ANY)
{
USE_OPLINE
uint32_t arg_num = opline->op1.num;
uint32_t arg_count = EX(num_args);
uint32_t arg_count = EX_NUM_ARGS();
zval *params;
SAVE_OPLINE();
@ -3589,7 +3576,7 @@ ZEND_VM_HANDLER(164, ZEND_RECV_VARIADIC, ANY, ANY)
param = EX_VAR_NUM(EX(func)->op_array.last_var + EX(func)->op_array.T);
if (UNEXPECTED((EX(func)->op_array.fn_flags & ZEND_ACC_HAS_TYPE_HINTS) != 0)) {
do {
zend_verify_arg_type(EX(func), arg_num, param TSRMLS_CC);
zend_verify_arg_type(EX(func), arg_num, param, NULL TSRMLS_CC);
zend_hash_next_index_insert_new(Z_ARRVAL_P(params), param);
if (Z_REFCOUNTED_P(param)) Z_ADDREF_P(param);
param++;
@ -3720,16 +3707,14 @@ ZEND_VM_HANDLER(68, ZEND_NEW, CONST|VAR, ANY)
if (RETURN_VALUE_USED(opline)) {
ZVAL_COPY_VALUE(EX_VAR(opline->result.var), &object_zval);
} else {
zval_ptr_dtor(&object_zval);
OBJ_RELEASE(Z_OBJ(object_zval));
}
ZEND_VM_JMP(opline->op2.jmp_addr);
} else {
/* We are not handling overloaded classes right now */
EX(call) = zend_vm_stack_push_call_frame(
VM_FRAME_INFO(
VM_FRAME_NESTED_FUNCTION,
RETURN_VALUE_USED(opline) ?
ZEND_CALL_CTOR : (ZEND_CALL_CTOR | ZEND_CALL_CTOR_RESULT_UNUSED)),
ZEND_CALL_FUNCTION | ZEND_CALL_CTOR |
(RETURN_VALUE_USED(opline) ? 0 : ZEND_CALL_CTOR_RESULT_UNUSED),
constructor,
opline->extended_value,
ce,
@ -3783,14 +3768,14 @@ ZEND_VM_HANDLER(110, ZEND_CLONE, CONST|TMP|VAR|UNUSED|CV, ANY)
if (clone->op_array.fn_flags & ZEND_ACC_PRIVATE) {
/* Ensure that if we're calling a private function, we're allowed to do so.
*/
if (UNEXPECTED(ce != EX(scope))) {
zend_error_noreturn(E_ERROR, "Call to private %s::__clone() from context '%s'", ce->name->val, EX(scope) ? EX(scope)->name->val : "");
if (UNEXPECTED(ce != EG(scope))) {
zend_error_noreturn(E_ERROR, "Call to private %s::__clone() from context '%s'", ce->name->val, EG(scope) ? EG(scope)->name->val : "");
}
} else if ((clone->common.fn_flags & ZEND_ACC_PROTECTED)) {
/* Ensure that if we're calling a protected function, we're allowed to do so.
*/
if (UNEXPECTED(!zend_check_protected(zend_get_function_root_class(clone), EX(scope)))) {
zend_error_noreturn(E_ERROR, "Call to protected %s::__clone() from context '%s'", ce->name->val, EX(scope) ? EX(scope)->name->val : "");
if (UNEXPECTED(!zend_check_protected(zend_get_function_root_class(clone), EG(scope)))) {
zend_error_noreturn(E_ERROR, "Call to protected %s::__clone() from context '%s'", ce->name->val, EG(scope) ? EG(scope)->name->val : "");
}
}
}
@ -3798,7 +3783,7 @@ ZEND_VM_HANDLER(110, ZEND_CLONE, CONST|TMP|VAR|UNUSED|CV, ANY)
if (EXPECTED(EG(exception) == NULL)) {
ZVAL_OBJ(EX_VAR(opline->result.var), clone_call(obj TSRMLS_CC));
if (!RETURN_VALUE_USED(opline) || UNEXPECTED(EG(exception) != NULL)) {
zval_ptr_dtor(EX_VAR(opline->result.var));
OBJ_RELEASE(Z_OBJ_P(EX_VAR(opline->result.var)));
}
}
FREE_OP1_IF_VAR();
@ -3884,7 +3869,7 @@ ZEND_VM_HANDLER(99, ZEND_FETCH_CONSTANT, VAR|CONST|UNUSED, CONST)
if (Z_CONSTANT_P(value)) {
EG(scope) = ce;
zval_update_constant(value, 1 TSRMLS_CC);
EG(scope) = EX(scope);
EG(scope) = EX(func)->op_array.scope;
}
if (OP1_TYPE == IS_CONST) {
CACHE_PTR(Z_CACHE_SLOT_P(opline->op2.zv), value);
@ -4205,7 +4190,7 @@ ZEND_VM_HANDLER(73, ZEND_INCLUDE_OR_EVAL, CONST|TMP|VAR|CV, ANY)
}
}
if (Z_TYPE(tmp_inc_filename) != IS_UNDEF) {
zval_ptr_dtor(&tmp_inc_filename);
zend_string_release(Z_STR(tmp_inc_filename));
}
FREE_OP1();
if (UNEXPECTED(EG(exception) != NULL)) {
@ -4218,7 +4203,9 @@ ZEND_VM_HANDLER(73, ZEND_INCLUDE_OR_EVAL, CONST|TMP|VAR|CV, ANY)
return_value = EX_VAR(opline->result.var);
}
call = zend_vm_stack_push_call_frame(VM_FRAME_NESTED_CODE,
new_op_array->scope = EG(scope); /* ??? */
call = zend_vm_stack_push_call_frame(ZEND_CALL_NESTED_CODE,
(zend_function*)new_op_array, 0, EX(called_scope), Z_OBJ(EX(This)), NULL TSRMLS_CC);
if (EX(symbol_table)) {
@ -4232,7 +4219,7 @@ ZEND_VM_HANDLER(73, ZEND_INCLUDE_OR_EVAL, CONST|TMP|VAR|CV, ANY)
if (EXPECTED(zend_execute_ex == execute_ex)) {
ZEND_VM_ENTER();
} else {
call->frame_info = VM_FRAME_TOP_CODE;
ZEND_ADD_CALL_FLAG(call, ZEND_CALL_TOP);
zend_execute_ex(call TSRMLS_CC);
}
@ -4296,8 +4283,8 @@ ZEND_VM_HANDLER(74, ZEND_UNSET_VAR, CONST|TMP|VAR|CV, UNUSED|CONST|VAR)
} else {
ce = zend_fetch_class_by_name(Z_STR_P(opline->op2.zv), opline->op2.zv + 1, 0 TSRMLS_CC);
if (UNEXPECTED(EG(exception) != NULL)) {
if (OP1_TYPE != IS_CONST) {
zval_dtor(&tmp);
if (OP1_TYPE != IS_CONST && Z_TYPE(tmp) != IS_UNDEF) {
zend_string_release(Z_STR(tmp));
}
FREE_OP1();
HANDLE_EXCEPTION();
@ -4316,8 +4303,8 @@ ZEND_VM_HANDLER(74, ZEND_UNSET_VAR, CONST|TMP|VAR|CV, UNUSED|CONST|VAR)
zend_hash_del_ind(target_symbol_table, Z_STR_P(varname));
}
if (OP1_TYPE != IS_CONST) {
zval_dtor(&tmp);
if (OP1_TYPE != IS_CONST && Z_TYPE(tmp) != IS_UNDEF) {
zend_string_release(Z_STR(tmp));
}
FREE_OP1();
CHECK_EXCEPTION();
@ -4339,8 +4326,8 @@ ZEND_VM_HANDLER(75, ZEND_UNSET_DIM, VAR|UNUSED|CV, CONST|TMP|VAR|CV)
}
if (OP1_TYPE != IS_UNUSED) {
ZVAL_DEREF(container);
SEPARATE_ZVAL_NOREF(container);
}
SEPARATE_ZVAL_NOREF(container);
offset = GET_OP2_ZVAL_PTR(BP_VAR_R);
if (OP1_TYPE != IS_UNUSED && EXPECTED(Z_TYPE_P(container) == IS_ARRAY)) {
@ -4423,7 +4410,9 @@ ZEND_VM_HANDLER(76, ZEND_UNSET_OBJ, VAR|UNUSED|CV, CONST|TMP|VAR|CV)
}
offset = GET_OP2_ZVAL_PTR(BP_VAR_R);
ZVAL_DEREF(container);
if (OP1_TYPE != IS_UNUSED) {
ZVAL_DEREF(container);
}
if (OP1_TYPE == IS_UNUSED || Z_TYPE_P(container) == IS_OBJECT) {
if (Z_OBJ_HT_P(container)->unset_property) {
Z_OBJ_HT_P(container)->unset_property(container, offset, ((OP2_TYPE == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(offset)) : NULL) TSRMLS_CC);
@ -4900,6 +4889,7 @@ ZEND_VM_HANDLER(114, ZEND_ISSET_ISEMPTY_VAR, CONST|TMP|VAR|CV, UNUSED|CONST|VAR)
zend_free_op free_op1;
zval tmp, *varname = GET_OP1_ZVAL_PTR(BP_VAR_IS);
ZVAL_UNDEF(&tmp);
if (OP1_TYPE != IS_CONST && Z_TYPE_P(varname) != IS_STRING) {
ZVAL_STR(&tmp, zval_get_string(varname));
varname = &tmp;
@ -4928,8 +4918,8 @@ ZEND_VM_HANDLER(114, ZEND_ISSET_ISEMPTY_VAR, CONST|TMP|VAR|CV, UNUSED|CONST|VAR)
value = zend_hash_find_ind(target_symbol_table, Z_STR_P(varname));
}
if (OP1_TYPE != IS_CONST && varname == &tmp) {
zval_dtor(&tmp);
if (OP1_TYPE != IS_CONST && Z_TYPE(tmp) != IS_UNDEF) {
zend_string_release(Z_STR(tmp));
}
FREE_OP1();
@ -5028,7 +5018,7 @@ ZEND_VM_C_LABEL(num_index_prop):
result = 0;
if (UNEXPECTED(Z_TYPE_P(offset) != IS_LONG)) {
if (OP1_TYPE == IS_CV || OP1_TYPE == IS_VAR) {
if (OP2_TYPE == IS_CV || OP2_TYPE == IS_VAR) {
ZVAL_DEREF(offset);
}
if (Z_TYPE_P(offset) < IS_STRING /* simple scalar types */
@ -5122,10 +5112,6 @@ ZEND_VM_HANDLER(57, ZEND_BEGIN_SILENCE, ANY, ANY)
SAVE_OPLINE();
ZVAL_LONG(EX_VAR(opline->result.var), EG(error_reporting));
if (EX(silence_op_num) == -1) {
EX(silence_op_num) = opline->op2.num;
EX(old_error_reporting) = EG(error_reporting);
}
if (EG(error_reporting)) {
do {
@ -5163,9 +5149,6 @@ ZEND_VM_HANDLER(58, ZEND_END_SILENCE, TMP, ANY)
if (!EG(error_reporting) && Z_LVAL_P(EX_VAR(opline->op1.var)) != 0) {
EG(error_reporting) = Z_LVAL_P(EX_VAR(opline->op1.var));
}
if (EX(silence_op_num) == opline->op2.num) {
EX(silence_op_num) = -1;
}
ZEND_VM_NEXT_OPCODE();
}
@ -5485,6 +5468,7 @@ ZEND_VM_HANDLER(149, ZEND_HANDLE_EXCEPTION, ANY, ANY)
}
if (op_num < EX(func)->op_array.try_catch_array[i].finally_op) {
finally_op_num = EX(func)->op_array.try_catch_array[i].finally_op;
finally_op_end = EX(func)->op_array.try_catch_array[i].finally_end;
}
if (op_num >= EX(func)->op_array.try_catch_array[i].finally_op &&
op_num < EX(func)->op_array.try_catch_array[i].finally_end) {
@ -5500,8 +5484,8 @@ ZEND_VM_HANDLER(149, ZEND_HANDLE_EXCEPTION, ANY, ANY)
zend_vm_stack_free_args(EX(call) TSRMLS_CC);
if (Z_OBJ(call->This)) {
if (call->frame_info & ZEND_CALL_CTOR) {
if (!(call->frame_info & ZEND_CALL_CTOR_RESULT_UNUSED)) {
if (ZEND_CALL_INFO(call) & ZEND_CALL_CTOR) {
if (!(ZEND_CALL_INFO(call) & ZEND_CALL_CTOR_RESULT_UNUSED)) {
GC_REFCOUNT(Z_OBJ(call->This))--;
}
if (GC_REFCOUNT(Z_OBJ(call->This)) == 1) {
@ -5531,40 +5515,47 @@ ZEND_VM_HANDLER(149, ZEND_HANDLE_EXCEPTION, ANY, ANY)
if (!(brk_opline->extended_value & EXT_TYPE_FREE_ON_RETURN)) {
zval_ptr_dtor_nogc(EX_VAR(brk_opline->op1.var));
}
} else if (brk_opline->opcode == ZEND_END_SILENCE) {
/* restore previous error_reporting value */
if (!EG(error_reporting) && Z_LVAL_P(EX_VAR(brk_opline->op1.var)) != 0) {
EG(error_reporting) = Z_LVAL_P(EX_VAR(brk_opline->op1.var));
}
}
}
}
}
/* restore previous error_reporting value */
if (!EG(error_reporting) && EX(silence_op_num) != -1 && EX(old_error_reporting) != 0) {
EG(error_reporting) = EX(old_error_reporting);
}
EX(silence_op_num) = -1;
if (finally_op_num && (!catch_op_num || catch_op_num >= finally_op_num)) {
if (EX(delayed_exception)) {
zend_exception_set_previous(EG(exception), EX(delayed_exception) TSRMLS_CC);
zval *fast_call = EX_VAR(EX(func)->op_array.opcodes[finally_op_end].op1.var);
if (Z_OBJ_P(fast_call)) {
zend_exception_set_previous(EG(exception), Z_OBJ_P(fast_call) TSRMLS_CC);
}
EX(delayed_exception) = EG(exception);
Z_OBJ_P(fast_call) = EG(exception);
EG(exception) = NULL;
EX(fast_ret) = NULL;
fast_call->u2.lineno = (uint32_t)-1;
ZEND_VM_SET_OPCODE(&EX(func)->op_array.opcodes[finally_op_num]);
ZEND_VM_CONTINUE();
} else if (catch_op_num) {
if (finally_op_end && catch_op_num > finally_op_end) {
/* we are going out of current finally scope */
if (EX(delayed_exception)) {
zend_exception_set_previous(EG(exception), EX(delayed_exception) TSRMLS_CC);
EX(delayed_exception) = NULL;
zval *fast_call = EX_VAR(EX(func)->op_array.opcodes[finally_op_end].op1.var);
if (Z_OBJ_P(fast_call)) {
zend_exception_set_previous(EG(exception), Z_OBJ_P(fast_call) TSRMLS_CC);
Z_OBJ_P(fast_call) = NULL;
}
}
ZEND_VM_SET_OPCODE(&EX(func)->op_array.opcodes[catch_op_num]);
ZEND_VM_CONTINUE();
} else {
if (EX(delayed_exception)) {
zend_exception_set_previous(EG(exception), EX(delayed_exception) TSRMLS_CC);
EX(delayed_exception) = NULL;
if (finally_op_end) {
zval *fast_call = EX_VAR(EX(func)->op_array.opcodes[finally_op_end].op1.var);
if (Z_OBJ_P(fast_call)) {
zend_exception_set_previous(EG(exception), Z_OBJ_P(fast_call) TSRMLS_CC);
Z_OBJ_P(fast_call) = NULL;
}
}
if (UNEXPECTED((EX(func)->op_array.fn_flags & ZEND_ACC_GENERATOR) != 0)) {
ZEND_VM_DISPATCH_TO_HANDLER(ZEND_GENERATOR_RETURN);
@ -5665,7 +5656,7 @@ ZEND_VM_HANDLER(153, ZEND_DECLARE_LAMBDA_FUNCTION, CONST, UNUSED)
if (closure_is_static || closure_is_being_defined_inside_static_context) {
zend_create_closure(EX_VAR(opline->result.var), Z_FUNC_P(zfunc), EX(called_scope), NULL TSRMLS_CC);
} else {
zend_create_closure(EX_VAR(opline->result.var), Z_FUNC_P(zfunc), EX(scope), Z_OBJ(EX(This)) ? &EX(This) : NULL TSRMLS_CC);
zend_create_closure(EX_VAR(opline->result.var), Z_FUNC_P(zfunc), EG(scope), Z_OBJ(EX(This)) ? &EX(This) : NULL TSRMLS_CC);
}
CHECK_EXCEPTION();
@ -5824,10 +5815,14 @@ ZEND_VM_HANDLER(160, ZEND_YIELD, CONST|TMP|VAR|CV|UNUSED, CONST|TMP|VAR|CV|UNUSE
ZEND_VM_HANDLER(159, ZEND_DISCARD_EXCEPTION, ANY, ANY)
{
if (EX(delayed_exception) != NULL) {
USE_OPLINE
zval *fast_call = EX_VAR(opline->op1.var);
/* check for delayed exception */
if (Z_OBJ_P(fast_call) != NULL) {
/* discard the previously thrown exception */
OBJ_RELEASE(EX(delayed_exception));
EX(delayed_exception) = NULL;
OBJ_RELEASE(Z_OBJ_P(fast_call));
Z_OBJ_P(fast_call) = NULL;
}
ZEND_VM_NEXT_OPCODE();
@ -5836,6 +5831,7 @@ ZEND_VM_HANDLER(159, ZEND_DISCARD_EXCEPTION, ANY, ANY)
ZEND_VM_HANDLER(162, ZEND_FAST_CALL, ANY, ANY)
{
USE_OPLINE
zval *fast_call = EX_VAR(opline->result.var);
if ((opline->extended_value & ZEND_FAST_CALL_FROM_CATCH) &&
UNEXPECTED(EG(prev_exception) != NULL)) {
@ -5843,18 +5839,24 @@ ZEND_VM_HANDLER(162, ZEND_FAST_CALL, ANY, ANY)
ZEND_VM_SET_OPCODE(&EX(func)->op_array.opcodes[opline->op2.opline_num]);
ZEND_VM_CONTINUE();
}
EX(fast_ret) = opline;
EX(delayed_exception) = NULL;
/* set no delayed exception */
Z_OBJ_P(fast_call) = NULL;
/* set return address */
fast_call->u2.lineno = opline - EX(func)->op_array.opcodes;
ZEND_VM_SET_OPCODE(opline->op1.jmp_addr);
ZEND_VM_CONTINUE();
}
ZEND_VM_HANDLER(163, ZEND_FAST_RET, ANY, ANY)
{
if (EX(fast_ret)) {
ZEND_VM_SET_OPCODE(EX(fast_ret) + 1);
if ((EX(fast_ret)->extended_value & ZEND_FAST_CALL_FROM_FINALLY)) {
EX(fast_ret) = &EX(func)->op_array.opcodes[EX(fast_ret)->op2.opline_num];
USE_OPLINE
zval *fast_call = EX_VAR(opline->op1.var);
if (fast_call->u2.lineno != (uint32_t)-1) {
const zend_op *fast_ret = EX(func)->op_array.opcodes + fast_call->u2.lineno;
ZEND_VM_SET_OPCODE(fast_ret + 1);
if (fast_ret->extended_value & ZEND_FAST_CALL_FROM_FINALLY) {
fast_call->u2.lineno = fast_ret->op2.opline_num;
}
ZEND_VM_CONTINUE();
} else {
@ -5865,8 +5867,8 @@ ZEND_VM_HANDLER(163, ZEND_FAST_RET, ANY, ANY)
ZEND_VM_SET_OPCODE(&EX(func)->op_array.opcodes[opline->op2.opline_num]);
ZEND_VM_CONTINUE();
} else {
EG(exception) = EX(delayed_exception);
EX(delayed_exception) = NULL;
EG(exception) = Z_OBJ_P(fast_call);
Z_OBJ_P(fast_call) = NULL;
if (opline->extended_value == ZEND_FAST_RET_TO_CATCH) {
ZEND_VM_SET_OPCODE(&EX(func)->op_array.opcodes[opline->op2.opline_num]);
ZEND_VM_CONTINUE();
@ -5906,23 +5908,39 @@ ZEND_VM_HANDLER(168, ZEND_BIND_GLOBAL, CV, CONST)
zval *varname;
zval *value;
zval *variable_ptr;
Bucket *p;
uint32_t idx;
SAVE_OPLINE();
varname = GET_OP2_ZVAL_PTR(BP_VAR_R);
idx = (uint32_t)(uintptr_t)CACHED_PTR(Z_CACHE_SLOT_P(varname));
/* index 0 can't be cached (NULL is a mark of uninitialized cache slot) */
p = EG(symbol_table).ht.arData + idx;
if (EXPECTED(idx > 0) &&
EXPECTED(idx < EG(symbol_table).ht.nNumUsed) &&
EXPECTED(Z_TYPE(p->val) != IS_UNDEF) &&
(EXPECTED(p->key == Z_STR_P(varname)) ||
(EXPECTED(p->h == Z_STR_P(varname)->h) &&
EXPECTED(p->key != NULL) &&
EXPECTED(p->key->len == Z_STRLEN_P(varname)) &&
EXPECTED(memcmp(p->key->val, Z_STRVAL_P(varname), Z_STRLEN_P(varname)) == 0)))) {
value = &EG(symbol_table).ht.arData[idx].val;
/* We store "hash slot index" + 1 (NULL is a mark of uninitialized cache slot) */
idx = (uint32_t)(uintptr_t)CACHED_PTR(Z_CACHE_SLOT_P(varname)) - 1;
if (EXPECTED(idx < EG(symbol_table).ht.nNumUsed)) {
Bucket *p = EG(symbol_table).ht.arData + idx;
if (EXPECTED(Z_TYPE(p->val) != IS_UNDEF) &&
(EXPECTED(p->key == Z_STR_P(varname)) ||
(EXPECTED(p->h == Z_STR_P(varname)->h) &&
EXPECTED(p->key != NULL) &&
EXPECTED(p->key->len == Z_STRLEN_P(varname)) &&
EXPECTED(memcmp(p->key->val, Z_STRVAL_P(varname), Z_STRLEN_P(varname)) == 0)))) {
value = &EG(symbol_table).ht.arData[idx].val;
ZEND_VM_C_GOTO(check_indirect);
}
}
value = zend_hash_find(&EG(symbol_table).ht, Z_STR_P(varname));
if (UNEXPECTED(value == NULL)) {
value = zend_hash_add_new(&EG(symbol_table).ht, Z_STR_P(varname), &EG(uninitialized_zval));
idx = ((char*)value - (char*)EG(symbol_table).ht.arData) / sizeof(Bucket);
/* Store "hash slot index" + 1 (NULL is a mark of uninitialized cache slot) */
CACHE_PTR(Z_CACHE_SLOT_P(varname), (void*)(uintptr_t)(idx + 1));
} else {
idx = ((char*)value - (char*)EG(symbol_table).ht.arData) / sizeof(Bucket);
/* Store "hash slot index" + 1 (NULL is a mark of uninitialized cache slot) */
CACHE_PTR(Z_CACHE_SLOT_P(varname), (void*)(uintptr_t)(idx + 1));
ZEND_VM_C_LABEL(check_indirect):
/* GLOBAL variable may be an INDIRECT pointer to CV */
if (UNEXPECTED(Z_TYPE_P(value) == IS_INDIRECT)) {
value = Z_INDIRECT_P(value);
@ -5930,23 +5948,6 @@ ZEND_VM_HANDLER(168, ZEND_BIND_GLOBAL, CV, CONST)
ZVAL_NULL(value);
}
}
} else {
value = zend_hash_find(&EG(symbol_table).ht, Z_STR_P(varname));
if (UNEXPECTED(value == NULL)) {
value = zend_hash_add_new(&EG(symbol_table).ht, Z_STR_P(varname), &EG(uninitialized_zval));
idx = ((char*)value - (char*)EG(symbol_table).ht.arData) / sizeof(Bucket);
CACHE_PTR(Z_CACHE_SLOT_P(varname), (void*)(uintptr_t)idx);
} else {
idx = ((char*)value - (char*)EG(symbol_table).ht.arData) / sizeof(Bucket);
CACHE_PTR(Z_CACHE_SLOT_P(varname), (void*)(uintptr_t)idx);
/* GLOBAL variable may be an INDIRECT pointer to CV */
if (UNEXPECTED(Z_TYPE_P(value) == IS_INDIRECT)) {
value = Z_INDIRECT_P(value);
if (UNEXPECTED(Z_TYPE_P(value) == IS_UNDEF)) {
ZVAL_NULL(value);
}
}
}
}
variable_ptr = GET_OP1_ZVAL_PTR_PTR_UNDEF(BP_VAR_W);

File diff suppressed because it is too large Load diff

View file

@ -34,7 +34,7 @@ ZEND_API void zend_{%EXECUTOR_NAME%}(zend_op_array *op_array, zval *return_value
return;
}
execute_data = zend_vm_stack_push_call_frame(VM_FRAME_TOP_CODE,
execute_data = zend_vm_stack_push_call_frame(ZEND_CALL_TOP_CODE,
(zend_function*)op_array, 0, EG(current_execute_data) ? EG(current_execute_data)->called_scope : NULL, EG(current_execute_data) ? Z_OBJ(EG(current_execute_data)->This) : NULL, NULL TSRMLS_CC);
if (EG(current_execute_data)) {
execute_data->symbol_table = zend_rebuild_symbol_table(TSRMLS_C);

View file

@ -100,18 +100,18 @@ $op2_type = array(
);
$op1_free = array(
"ANY" => "(free_op1.var != NULL)",
"ANY" => "(free_op1 != NULL)",
"TMP" => "1",
"VAR" => "(free_op1.var != NULL)",
"VAR" => "(free_op1 != NULL)",
"CONST" => "0",
"UNUSED" => "0",
"CV" => "0",
);
$op2_free = array(
"ANY" => "(free_op2.var != NULL)",
"ANY" => "(free_op2 != NULL)",
"TMP" => "1",
"VAR" => "(free_op2.var != NULL)",
"VAR" => "(free_op2 != NULL)",
"CONST" => "0",
"UNUSED" => "0",
"CV" => "0",
@ -119,8 +119,8 @@ $op2_free = array(
$op1_get_zval_ptr = array(
"ANY" => "get_zval_ptr(opline->op1_type, &opline->op1, execute_data, &free_op1, \\1)",
"TMP" => "_get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC)",
"VAR" => "_get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC)",
"TMP" => "_get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1)",
"VAR" => "_get_zval_ptr_var(opline->op1.var, execute_data, &free_op1)",
"CONST" => "opline->op1.zv",
"UNUSED" => "NULL",
"CV" => "_get_zval_ptr_cv_\\1(execute_data, opline->op1.var TSRMLS_CC)",
@ -128,8 +128,8 @@ $op1_get_zval_ptr = array(
$op2_get_zval_ptr = array(
"ANY" => "get_zval_ptr(opline->op2_type, &opline->op2, execute_data, &free_op2, \\1)",
"TMP" => "_get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC)",
"VAR" => "_get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC)",
"TMP" => "_get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2)",
"VAR" => "_get_zval_ptr_var(opline->op2.var, execute_data, &free_op2)",
"CONST" => "opline->op2.zv",
"UNUSED" => "NULL",
"CV" => "_get_zval_ptr_cv_\\1(execute_data, opline->op2.var TSRMLS_CC)",
@ -138,7 +138,7 @@ $op2_get_zval_ptr = array(
$op1_get_zval_ptr_ptr = array(
"ANY" => "get_zval_ptr_ptr(opline->op1_type, &opline->op1, execute_data, &free_op1, \\1)",
"TMP" => "NULL",
"VAR" => "_get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC)",
"VAR" => "_get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1)",
"CONST" => "NULL",
"UNUSED" => "NULL",
"CV" => "_get_zval_ptr_cv_\\1(execute_data, opline->op1.var TSRMLS_CC)",
@ -147,7 +147,7 @@ $op1_get_zval_ptr_ptr = array(
$op2_get_zval_ptr_ptr = array(
"ANY" => "get_zval_ptr_ptr(opline->op2_type, &opline->op2, execute_data, &free_op2, \\1)",
"TMP" => "NULL",
"VAR" => "_get_zval_ptr_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC)",
"VAR" => "_get_zval_ptr_ptr_var(opline->op2.var, execute_data, &free_op2)",
"CONST" => "NULL",
"UNUSED" => "NULL",
"CV" => "_get_zval_ptr_cv_\\1(execute_data, opline->op2.var TSRMLS_CC)",
@ -155,8 +155,8 @@ $op2_get_zval_ptr_ptr = array(
$op1_get_zval_ptr_deref = array(
"ANY" => "get_zval_ptr_deref(opline->op1_type, &opline->op1, execute_data, &free_op1, \\1)",
"TMP" => "_get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC)",
"VAR" => "_get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1 TSRMLS_CC)",
"TMP" => "_get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1)",
"VAR" => "_get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1)",
"CONST" => "opline->op1.zv",
"UNUSED" => "NULL",
"CV" => "_get_zval_ptr_cv_deref_\\1(execute_data, opline->op1.var TSRMLS_CC)",
@ -164,8 +164,8 @@ $op1_get_zval_ptr_deref = array(
$op2_get_zval_ptr_deref = array(
"ANY" => "get_zval_ptr_deref(opline->op2_type, &opline->op2, execute_data, &free_op2, \\1)",
"TMP" => "_get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC)",
"VAR" => "_get_zval_ptr_var_deref(opline->op2.var, execute_data, &free_op2 TSRMLS_CC)",
"TMP" => "_get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2)",
"VAR" => "_get_zval_ptr_var_deref(opline->op2.var, execute_data, &free_op2)",
"CONST" => "opline->op2.zv",
"UNUSED" => "NULL",
"CV" => "_get_zval_ptr_cv_deref_\\1(execute_data, opline->op2.var TSRMLS_CC)",
@ -174,7 +174,7 @@ $op2_get_zval_ptr_deref = array(
$op1_get_zval_ptr_ptr_undef = array(
"ANY" => "get_zval_ptr_ptr_undef(opline->op1_type, &opline->op1, execute_data, &free_op1, \\1)",
"TMP" => "NULL",
"VAR" => "_get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC)",
"VAR" => "_get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1)",
"CONST" => "NULL",
"UNUSED" => "NULL",
"CV" => "_get_zval_ptr_cv_undef_\\1(execute_data, opline->op1.var TSRMLS_CC)",
@ -183,7 +183,7 @@ $op1_get_zval_ptr_ptr_undef = array(
$op2_get_zval_ptr_ptr_undef = array(
"ANY" => "get_zval_ptr_ptr_undef(opline->op2_type, &opline->op2, execute_data, &free_op2, \\1)",
"TMP" => "NULL",
"VAR" => "_get_zval_ptr_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC)",
"VAR" => "_get_zval_ptr_ptr_var(opline->op2.var, execute_data, &free_op2)",
"CONST" => "NULL",
"UNUSED" => "NULL",
"CV" => "_get_zval_ptr_cv_undef_\\1(execute_data, opline->op2.var TSRMLS_CC)",
@ -191,62 +191,62 @@ $op2_get_zval_ptr_ptr_undef = array(
$op1_get_obj_zval_ptr = array(
"ANY" => "get_obj_zval_ptr(opline->op1_type, &opline->op1, execute_data, &free_op1, \\1)",
"TMP" => "_get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC)",
"VAR" => "_get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC)",
"TMP" => "_get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1)",
"VAR" => "_get_zval_ptr_var(opline->op1.var, execute_data, &free_op1)",
"CONST" => "opline->op1.zv",
"UNUSED" => "_get_obj_zval_ptr_unused(TSRMLS_C)",
"UNUSED" => "_get_obj_zval_ptr_unused(execute_data)",
"CV" => "_get_zval_ptr_cv_\\1(execute_data, opline->op1.var TSRMLS_CC)",
);
$op2_get_obj_zval_ptr = array(
"ANY" => "get_obj_zval_ptr(opline->op2_type, &opline->op2, execute_data, &free_op2, \\1)",
"TMP" => "_get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC)",
"VAR" => "_get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC)",
"TMP" => "_get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2)",
"VAR" => "_get_zval_ptr_var(opline->op2.var, execute_data, &free_op2)",
"CONST" => "opline->op2.zv",
"UNUSED" => "_get_obj_zval_ptr_unused(TSRMLS_C)",
"UNUSED" => "_get_obj_zval_ptr_unused(execute_data)",
"CV" => "_get_zval_ptr_cv_\\1(execute_data, opline->op2.var TSRMLS_CC)",
);
$op1_get_obj_zval_ptr_deref = array(
"ANY" => "get_obj_zval_ptr(opline->op1_type, &opline->op1, execute_data, &free_op1, \\1)",
"TMP" => "_get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC)",
"VAR" => "_get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1 TSRMLS_CC)",
"TMP" => "_get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1)",
"VAR" => "_get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1)",
"CONST" => "opline->op1.zv",
"UNUSED" => "_get_obj_zval_ptr_unused(execute_data TSRMLS_CC)",
"UNUSED" => "_get_obj_zval_ptr_unused(execute_data)",
"CV" => "_get_zval_ptr_cv_deref_\\1(execute_data, opline->op1.var TSRMLS_CC)",
);
$op2_get_obj_zval_ptr_deref = array(
"ANY" => "get_obj_zval_ptr(opline->op2_type, &opline->op2, execute_data, &free_op2, \\1)",
"TMP" => "_get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC)",
"VAR" => "_get_zval_ptr_var_deref(opline->op2.var, execute_data, &free_op2 TSRMLS_CC)",
"TMP" => "_get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2)",
"VAR" => "_get_zval_ptr_var_deref(opline->op2.var, execute_data, &free_op2)",
"CONST" => "opline->op2.zv",
"UNUSED" => "_get_obj_zval_ptr_unused(execute_data TSRMLS_CC)",
"UNUSED" => "_get_obj_zval_ptr_unused(execute_data)",
"CV" => "_get_zval_ptr_cv_deref_\\1(execute_data, opline->op2.var TSRMLS_CC)",
);
$op1_get_obj_zval_ptr_ptr = array(
"ANY" => "get_obj_zval_ptr_ptr(opline->op1_type, &opline->op1, execute_data, &free_op1, \\1)",
"TMP" => "NULL",
"VAR" => "_get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC)",
"VAR" => "_get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1)",
"CONST" => "NULL",
"UNUSED" => "_get_obj_zval_ptr_unused(execute_data TSRMLS_CC)",
"UNUSED" => "_get_obj_zval_ptr_unused(execute_data)",
"CV" => "_get_zval_ptr_cv_\\1(execute_data, opline->op1.var TSRMLS_CC)",
);
$op2_get_obj_zval_ptr_ptr = array(
"ANY" => "get_obj_zval_ptr_ptr(opline->op2_type, &opline->op2, execute_data, &free_op2, \\1)",
"TMP" => "NULL",
"VAR" => "_get_zval_ptr_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC)",
"VAR" => "_get_zval_ptr_ptr_var(opline->op2.var, execute_data, &free_op2)",
"CONST" => "NULL",
"UNUSED" => "_get_obj_zval_ptr_unused(execute_data TSRMLS_CC)",
"UNUSED" => "_get_obj_zval_ptr_unused(execute_data)",
"CV" => "_get_zval_ptr_cv_\\1(execute_data, opline->op2.var TSRMLS_CC)",
);
$op1_free_op = array(
"ANY" => "FREE_OP(free_op1)",
"TMP" => "zval_ptr_dtor_nogc(free_op1.var)",
"VAR" => "zval_ptr_dtor_nogc(free_op1.var)",
"TMP" => "zval_ptr_dtor_nogc(free_op1)",
"VAR" => "zval_ptr_dtor_nogc(free_op1)",
"CONST" => "",
"UNUSED" => "",
"CV" => "",
@ -254,44 +254,44 @@ $op1_free_op = array(
$op2_free_op = array(
"ANY" => "FREE_OP(free_op2)",
"TMP" => "zval_ptr_dtor_nogc(free_op2.var)",
"VAR" => "zval_ptr_dtor_nogc(free_op2.var)",
"TMP" => "zval_ptr_dtor_nogc(free_op2)",
"VAR" => "zval_ptr_dtor_nogc(free_op2)",
"CONST" => "",
"UNUSED" => "",
"CV" => "",
);
$op1_free_op_if_var = array(
"ANY" => "if (opline->op1_type == IS_VAR) {zval_ptr_dtor_nogc(free_op1.var);}",
"ANY" => "if (opline->op1_type == IS_VAR) {zval_ptr_dtor_nogc(free_op1);}",
"TMP" => "",
"VAR" => "zval_ptr_dtor_nogc(free_op1.var)",
"VAR" => "zval_ptr_dtor_nogc(free_op1)",
"CONST" => "",
"UNUSED" => "",
"CV" => "",
);
$op2_free_op_if_var = array(
"ANY" => "if (opline->op1_type == IS_VAR) {zval_ptr_dtor_nogc(free_op1.var);}",
"ANY" => "if (opline->op2_type == IS_VAR) {zval_ptr_dtor_nogc(free_op2);}",
"TMP" => "",
"VAR" => "zval_ptr_dtor_nogc(free_op2.var)",
"VAR" => "zval_ptr_dtor_nogc(free_op2)",
"CONST" => "",
"UNUSED" => "",
"CV" => "",
);
$op1_free_op_var_ptr = array(
"ANY" => "if (free_op1.var) {zval_ptr_dtor_nogc(free_op1.var);}",
"ANY" => "if (free_op1) {zval_ptr_dtor_nogc(free_op1);}",
"TMP" => "",
"VAR" => "if (free_op1.var) {zval_ptr_dtor_nogc(free_op1.var);}",
"VAR" => "if (free_op1) {zval_ptr_dtor_nogc(free_op1);}",
"CONST" => "",
"UNUSED" => "",
"CV" => "",
);
$op2_free_op_var_ptr = array(
"ANY" => "if (free_op2.var) {zval_ptr_dtor_nogc(free_op2.var);}",
"ANY" => "if (free_op2) {zval_ptr_dtor_nogc(free_op2);}",
"TMP" => "",
"VAR" => "if (free_op2.var) {zval_ptr_dtor_nogc(free_op2.var);}",
"VAR" => "if (free_op2) {zval_ptr_dtor_nogc(free_op2);}",
"CONST" => "",
"UNUSED" => "",
"CV" => "",
@ -1217,7 +1217,9 @@ function gen_vm($def, $skel) {
out($f, $GLOBALS['header_text']);
fputs($f, "#ifndef ZEND_VM_OPCODES_H\n#define ZEND_VM_OPCODES_H\n\n");
fputs($f, "BEGIN_EXTERN_C()\n\n");
fputs($f, "ZEND_API const char *zend_get_opcode_name(zend_uchar opcode);\n\n");
fputs($f, "END_EXTERN_C()\n\n");
foreach ($opcodes as $code => $dsc) {
$code = str_pad((string)$code,$code_len," ",STR_PAD_LEFT);

View file

@ -21,8 +21,12 @@
#ifndef ZEND_VM_OPCODES_H
#define ZEND_VM_OPCODES_H
BEGIN_EXTERN_C()
ZEND_API const char *zend_get_opcode_name(zend_uchar opcode);
END_EXTERN_C()
#define ZEND_NOP 0
#define ZEND_ADD 1
#define ZEND_SUB 2

View file

@ -47,7 +47,7 @@
*
* CALENDAR OVERVIEW
*
* Julias Ceasar created the calendar in 46 B.C. as a modified form of
* Julius Caesar created the calendar in 46 B.C. as a modified form of
* the old Roman republican calendar which was based on lunar cycles.
* The new Julian calendar set fixed lengths for the months, abandoning
* the lunar cycle. It also specified that there would be exactly 12

View file

@ -21,10 +21,10 @@ putenv('TZ=UTC');
// -uses --INI-- section with date.timezone=UTC
// -uses putenv('TZ=UTC')
// date.timezone=UTC
// -if ommitted from easter_date.phpt, outputs DATE_TZ_ERRMSG warning
// -if omitted from easter_date.phpt, outputs DATE_TZ_ERRMSG warning
// -easter_date() calls mktime() and localtime()
// -whereas unixtojd(1000000000) calls localtime(1000000000)
// -if ommitted from unixtojd.phpt, does NOT output DATE_TZ_ERRMSG
// -if omitted from unixtojd.phpt, does NOT output DATE_TZ_ERRMSG
//
// unixtojd() calls php_localtime_r() which for Pacific timezone systems, returns a time -8 hours
// -this incorrect localtime is passed to the julian date conversion (GregorianToSDN) function which works (probably correctly)

View file

@ -254,7 +254,7 @@ PHP_FUNCTION(com_create_instance)
ITypeLib_Release(TL);
}
} else if (obj->typeinfo && COMG(autoreg_on)) {
int idx;
UINT idx;
if (SUCCEEDED(ITypeInfo_GetContainingTypeLib(obj->typeinfo, &TL, &idx))) {
/* check if the library is already in the cache by getting its name */
@ -693,7 +693,6 @@ PHP_FUNCTION(com_event_sink)
{
zval *object, *sinkobject, *sink=NULL;
char *dispname = NULL, *typelibname = NULL;
zend_bool gotguid = 0;
php_com_dotnet_object *obj;
ITypeInfo *typeinfo = NULL;

View file

@ -387,7 +387,7 @@ PHP_MINIT_FUNCTION(com_dotnet)
#define COM_ERR_CONST(x) { \
zend_long __tmp; \
ULongToUIntPtr(x, &__tmp); \
ULongToIntPtr(x, &__tmp); \
REGISTER_LONG_CONSTANT(#x, __tmp, CONST_CS|CONST_PERSISTENT); \
}

View file

@ -67,11 +67,11 @@ PHP_COM_DOTNET_API ITypeLib *php_com_load_typelib(char *search_string, int codep
hr = LoadRegTypeLib((REFGUID)&clsid, major_i, minor_i, LANG_NEUTRAL, &TL);
/* if that failed, assumed that the GUID is actually a CLSID and
* attemp to get the library via an instance of that class */
* attempt to get the library via an instance of that class */
if (FAILED(hr) && (major == NULL || minor == NULL)) {
IDispatch *disp = NULL;
ITypeInfo *info = NULL;
int idx;
UINT idx;
if (SUCCEEDED(hr = CoCreateInstance(&clsid, NULL, CLSCTX_SERVER, &IID_IDispatch, (LPVOID*)&disp)) &&
SUCCEEDED(hr = IDispatch_GetTypeInfo(disp, 0, LANG_NEUTRAL, &info))) {
@ -96,7 +96,7 @@ PHP_COM_DOTNET_API ITypeLib *php_com_load_typelib(char *search_string, int codep
DWORD VersionCount;
char version[20];
char *libname;
DWORD libnamelen;
long libnamelen;
if (ERROR_SUCCESS == RegOpenKeyEx(HKEY_CLASSES_ROOT, "TypeLib", 0, KEY_READ, &hkey) &&
ERROR_SUCCESS == RegQueryInfoKey(hkey, NULL, NULL, NULL, &SubKeys,
@ -116,7 +116,7 @@ PHP_COM_DOTNET_API ITypeLib *php_com_load_typelib(char *search_string, int codep
continue;
}
/* get the default value for this key and compare */
libnamelen = (DWORD)strlen(search_string)+1;
libnamelen = (long)strlen(search_string)+1;
if (ERROR_SUCCESS == RegQueryValue(hsubkey, version, libname, &libnamelen)) {
if (0 == stricmp(libname, search_string)) {
char *str = NULL;

View file

@ -39,8 +39,7 @@ static void safe_array_from_zval(VARIANT *v, zval *z, int codepage TSRMLS_DC)
HashPosition pos;
int keytype;
zend_string *strindex;
zend_long intindex = -1;
zend_long max_index = 0;
zend_ulong intindex = 0;
VARIANT *va;
zval *item;
@ -54,15 +53,15 @@ static void safe_array_from_zval(VARIANT *v, zval *z, int codepage TSRMLS_DC)
goto bogus;
} else if (HASH_KEY_NON_EXISTENT == keytype) {
break;
}
if (intindex > max_index) {
max_index = intindex;
} else if (intindex > UINT_MAX) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "COM: max number %u of elements in safe array exceeded", UINT_MAX);
break;
}
}
/* allocate the structure */
bound.lLbound = 0;
bound.cElements = (ULONG)(intindex + 1);
bound.cElements = zend_hash_num_elements(HASH_OF(z));
sa = SafeArrayCreate(VT_VARIANT, 1, &bound);
/* get a lock on the array itself */

View file

@ -9,7 +9,7 @@
current locale.
</para>
<para>
When called with an integer argument theese functions
When called with an integer argument these functions
behave exactly like their C counterparts.
</para>
<para>

View file

@ -0,0 +1,27 @@
--TEST--
Test curl_multi_init() fail if any parameter is passed
--CREDITS--
Paulo Eduardo <pauloelr [at] gmail [dot] com>
#testfest SP 2014
--SKIPIF--
<?php if (!extension_loaded("curl")) print "skip"; ?>
--FILE--
<?php
/* Prototype : resource curl_multi_init(void)
* Description : Returns a new cURL multi handle
* Source code : ext/curl/multi.c
* Test documentation: http://wiki.php.net/qa/temp/ext/curl
*/
// start testing
//create the multiple cURL handle
$mh = curl_multi_init('test');
var_dump($mh);
?>
===DONE===
--EXPECTF--
Warning: curl_multi_init() expects exactly 0 parameters, %d given in %s on line %d
NULL
===DONE===

View file

@ -336,7 +336,7 @@ static ttinfo* fetch_timezone_offset(timelib_tzinfo *tz, timelib_sll ts, timelib
{
uint32_t i;
/* If there is no transistion time, we pick the first one, if that doesn't
/* If there is no transition time, we pick the first one, if that doesn't
* exist we return NULL */
if (!tz->timecnt || !tz->trans) {
*transition_time = 0;
@ -346,8 +346,8 @@ static ttinfo* fetch_timezone_offset(timelib_tzinfo *tz, timelib_sll ts, timelib
return NULL;
}
/* If the TS is lower than the first transistion time, then we scan over
* all the transistion times to find the first non-DST one, or the first
/* If the TS is lower than the first transition time, then we scan over
* all the transition times to find the first non-DST one, or the first
* one in case there are only DST entries. Not sure which smartass came up
* with this idea in the first though :) */
if (ts < tz->trans[0]) {

File diff suppressed because it is too large Load diff

View file

@ -3,7 +3,7 @@ strtotime() function
--SKIPIF--
<?php
if (!@putenv("TZ=EST5") || getenv("TZ") != 'EST5') {
die("skip unable to change TZ enviroment variable\n");
die("skip unable to change TZ environment variable\n");
}
?>
--FILE--

View file

@ -8,7 +8,7 @@ if (defined('PHP_WINDOWS_VERSION_MAJOR')) {
die("skip. set TZ env is not supported at runtime.");
}
if (!@putenv("TZ=US/Eastern") || getenv("TZ") != 'US/Eastern') {
die("skip unable to change TZ enviroment variable\n");
die("skip unable to change TZ environment variable\n");
}
?>
--FILE--

View file

@ -4,7 +4,7 @@ Bug #26317 (military timezone offset signedness)
date.timezone=GMT0
--SKIPIF--
if (!@putenv("TZ=GMT0") || getenv("TZ") != 'GMT0') {
die("skip unable to change TZ enviroment variable\n");
die("skip unable to change TZ environment variable\n");
}
--FILE--
<?php

View file

@ -4,7 +4,7 @@ Bug #26320 (strtotime handling of XML Schema/ISO 8601 format)
date.timezone=GMT0
--SKIPIF--
if (!@putenv("TZ=GMT0") || getenv("TZ") != 'GMT0') {
die("skip unable to change TZ enviroment variable\n");
die("skip unable to change TZ environment variable\n");
}
--FILE--
<?php

View file

@ -0,0 +1,34 @@
--TEST--
Test date_interval_create_from_date_string() function : basic functionality
--CREDITS--
Rodrigo Prado de Jesus <royopa [at] gmail [dot] com>
--FILE--
<?php
$string = '1 day'; //P1D
$i = date_interval_create_from_date_string($string);
var_dump($i->d);
$string = '2 weeks'; //14 days
$i = date_interval_create_from_date_string($string);
var_dump($i->d);
$string = '3 months';
$i = date_interval_create_from_date_string($string);
var_dump($i->m);
$string = '4 years';
$i = date_interval_create_from_date_string($string);
var_dump($i->y);
$string = '1 year + 1 day';
$i = date_interval_create_from_date_string($string);
var_dump($i->y);
var_dump($i->d);
?>
--EXPECTF--
int(1)
int(14)
int(3)
int(4)
int(1)
int(1)

View file

@ -0,0 +1,42 @@
--TEST--
Test date_interval_create_from_date_string() function : null parameter
--CREDITS--
Rodrigo Prado de Jesus <royopa [at] gmail [dot] com>
--FILE--
<?php
$i = date_interval_create_from_date_string(null); //returns a empty object
var_dump($i);
?>
--EXPECTF--
object(DateInterval)#1 (15) {
["y"]=>
int(0)
["m"]=>
int(0)
["d"]=>
int(0)
["h"]=>
int(0)
["i"]=>
int(0)
["s"]=>
int(0)
["weekday"]=>
int(0)
["weekday_behavior"]=>
int(0)
["first_last_day_of"]=>
int(0)
["invert"]=>
int(0)
["days"]=>
int(0)
["special_type"]=>
int(0)
["special_amount"]=>
int(0)
["have_weekday_relative"]=>
int(0)
["have_special_relative"]=>
int(0)
}

View file

@ -0,0 +1,11 @@
--TEST--
Test date_interval_create_from_date_string() function : wrong parameter (array)
--CREDITS--
Rodrigo Prado de Jesus <royopa [at] gmail [dot] com>
--FILE--
<?php
$wrong_parameter = array();
$i = date_interval_create_from_date_string($wrong_parameter);
?>
--EXPECTF--
Warning: date_interval_create_from_date_string() expects parameter 1 to be string, array given in %s on line %d

View file

@ -0,0 +1,9 @@
--TEST--
Test date_interval_create_from_date_string() function : with 2 parameters (wrong).
Rodrigo Prado de Jesus <royopa [at] gmail [dot] com>
--FILE--
<?php
$i = date_interval_create_from_date_string('1 year', 'wrong');
?>
--EXPECTF--
Warning: date_interval_create_from_date_string() expects exactly 1 parameter, 2 given in %s on line %d

View file

@ -0,0 +1,19 @@
--TEST--
Test the basics to function date_timestamp_set().
--CREDITS--
Rodrigo Prado de Jesus <royopa [at] gmail [dot] com>
--INI--
date.timezone = UTC;
date_default_timezone_set("America/Sao_Paulo");
--FILE--
<?php
$dftz021 = date_default_timezone_get(); //UTC
$dtms021 = date_create();
date_timestamp_set($dtms021, 1234567890);
var_dump(date_format($dtms021, 'B => (U) => T Y-M-d H:i:s'));
?>
--EXPECTF--
string(47) "021 => (1234567890) => UTC 2009-Feb-13 23:31:30"

View file

@ -0,0 +1,17 @@
--TEST--
Test the function date_timestamp_set() with first null parameter.
--CREDITS--
Rodrigo Prado de Jesus <royopa [at] gmail [dot] com>
--INI--
date.timezone = UTC;
date_default_timezone_set("America/Sao_Paulo");
--FILE--
<?php
$dftz021 = date_default_timezone_get(); //UTC
$dtms021 = date_create();
date_timestamp_set(null, 1234567890);
?>
--EXPECTF--
Warning: date_timestamp_set() expects parameter 1 to be DateTime, null given in %s on line %d

View file

@ -0,0 +1,24 @@
--TEST--
Test the function date_timestamp_set() with second null parameter.
--CREDITS--
Rodrigo Prado de Jesus <royopa [at] gmail [dot] com>
--INI--
date.timezone = UTC;
date_default_timezone_set("America/Sao_Paulo");
--FILE--
<?php
$dftz021 = date_default_timezone_get(); //UTC
$dtms021 = date_create();
var_dump(date_timestamp_set($dtms021, null));
?>
--EXPECTF--
object(DateTime)#1 (3) {
["date"]=>
string(26) "1970-01-01 00:00:00.000000"
["timezone_type"]=>
int(3)
["timezone"]=>
string(3) "UTC"
}

View file

@ -0,0 +1,17 @@
--TEST--
Check the function date_timestamp_set() with first parameter wrong (array).
--CREDITS--
Rodrigo Prado de Jesus <royopa [at] gmail [dot] com>
--INI--
date.timezone = UTC;
date_default_timezone_set("America/Sao_Paulo");
--FILE--
<?php
$dftz021 = date_default_timezone_get(); //UTC
$dtms021 = array();
date_timestamp_set($dtms021, 123456789);
?>
--EXPECTF--
Warning: date_timestamp_set() expects parameter 1 to be DateTime, array given in %s on line %d

View file

@ -0,0 +1,15 @@
--TEST--
Check the function date_timestamp_set() with first parameter wrong (integer).
--CREDITS--
Rodrigo Prado de Jesus <royopa [at] gmail [dot] com>
--INI--
date.timezone = UTC;
date_default_timezone_set("America/Sao_Paulo");
--FILE--
<?php
$dftz021 = date_default_timezone_get(); //UTC
date_timestamp_set(987654321, 123456789);
?>
--EXPECTF--
Warning: date_timestamp_set() expects parameter 1 to be DateTime, integer given in %s on line %d

View file

@ -0,0 +1,19 @@
--TEST--
Check the function date_timestamp_set() with second parameter wrong (array).
--CREDITS--
Rodrigo Prado de Jesus <royopa [at] gmail [dot] com>
--INI--
date.timezone = UTC;
date_default_timezone_set("America/Sao_Paulo");
--FILE--
<?php
$dftz021 = date_default_timezone_get(); //UTC
$dtms021 = new DateTime();
$wrong_parameter = array();
date_timestamp_set($dtms021, $wrong_parameter);
?>
--EXPECTF--
Warning: date_timestamp_set() expects parameter 2 to be long, array given in %s on line %d

View file

@ -0,0 +1,17 @@
--TEST--
Check the function date_timestamp_set() with 3 parameters.
--CREDITS--
Rodrigo Prado de Jesus <royopa [at] gmail [dot] com>
--INI--
date.timezone = UTC;
date_default_timezone_set("America/Sao_Paulo");
--FILE--
<?php
$dftz021 = date_default_timezone_get(); //UTC
$dtms021 = new DateTime();
date_timestamp_set($dtms021, 123456789, 'error');
?>
--EXPECTF--
Warning: date_timestamp_set() expects exactly 2 parameters, 3 given in %s on line %d

View file

@ -0,0 +1,13 @@
--TEST--
Test the basics to function timezone_version_get().
--CREDITS--
Rodrigo Prado de Jesus <royopa [at] gmail [dot] com>
--INI--
date.timezone = UTC;
date_default_timezone_set("America/Sao_Paulo");
--FILE--
<?php
var_dump(timezone_version_get());
?>
--EXPECTREGEX--
string\([6-7]\) \"20[0-9][0-9]\.[1-9][0-9]?\"

View file

@ -0,0 +1,12 @@
--TEST--
timezone_version_get: Test that timezone_location_get returns a date concatenated with a dot and a version number
--CREDITS--
Rodrigo Wanderley de Melo Cardoso <rodrigogepem@gmail.com>
#PHPTestFest2014 São Paulo 2014-07-05
--INI--
date.timezone=UTC
--FILE--
<?php $versionTimezone = timezone_version_get();
echo $versionTimezone; ?>
--EXPECTREGEX--
^[12][0-9]{3}.[0-9]+$

View file

@ -39,7 +39,7 @@ inifile This is available since PHP 4.3.3 to be able to modify php.ini
As the functions dba_firstkey() and dba_nextkey() return string
representations of the key there is a new function dba_key_split()
available since PHP 5 which allows to convert the string keys into
array keys without loosing FALSE.
array keys without losing FALSE.
qdbm This is available since PHP 5.0.0. The qdbm library can be loaded
from http://qdbm.sourceforge.net.

View file

@ -450,7 +450,7 @@ int starordinary; /* is a leading * an ordinary character? */
register sopno subno;
# define BACKSL (1<<CHAR_BIT)
pos = HERE(); /* repetion op, if any, covers from here */
pos = HERE(); /* repetition op, if any, covers from here */
assert(MORE()); /* caller should have ensured this */
c = GETNEXT();

View file

@ -10,8 +10,8 @@ var_dump(exif_thumbnail(__DIR__."/bug68113.jpg"));
?>
Done
--EXPECTF--
Warning: exif_thumbnail(bug68113.jpg): File structure corrupted in %s/bug68113.php on line 2
Warning: exif_thumbnail(bug68113.jpg): File structure corrupted in %s%ebug68113.php on line 2
Warning: exif_thumbnail(bug68113.jpg): Invalid JPEG file in %s/bug68113.php on line 2
Warning: exif_thumbnail(bug68113.jpg): Invalid JPEG file in %s%ebug68113.php on line 2
bool(false)
Done
Done

View file

@ -3,7 +3,7 @@ if(!extension_loaded('fileinfo')) {
dl('fileinfo.' . PHP_SHLIB_SUFFIX);
}
if(!extension_loaded('fileinfo')) {
die("fileinfo extension is not avaliable, please compile it.\n");
die("fileinfo extension is not available, please compile it.\n");
}
// normal operation

View file

@ -351,7 +351,7 @@
*
* Revision 1.8 93/02/19 15:01:26 ian
* Numerous changes from Guy Harris too numerous to mention but including
* byte-order independance, fixing "old-style masking", etc. etc. A bugfix
* byte-order independence, fixing "old-style masking", etc. etc. A bugfix
* for broken symlinks from martin@@d255s004.zfe.siemens.de.
*
* Revision 1.7 93/01/05 14:57:27 ian

View file

@ -3918,7 +3918,7 @@
>7 string x version %.2s
# We skip the path here, because it is often long (so file will
# truncate it) and mostly redundant.
# The inverted index functionality was added some time betwen
# The inverted index functionality was added some time between
# versions 11 and 15, so look for -q if version is above 14:
>7 string >14
>>10 search/100 \ -q\ with inverted index
@ -3972,7 +3972,7 @@
# .cwk
0 string \002\000\210\003\102\117\102\117\000\001\206 Claris works document
# .plt
0 string \020\341\000\000\010\010 Claris Works pallete files .plt
0 string \020\341\000\000\010\010 Claris Works palette files .plt
# .msp a dictionary file I am not sure about this I have only one .msp file
0 string \002\271\262\000\040\002\000\164 Claris works dictionary
@ -4443,9 +4443,9 @@
>6 byte&0x04 =0x8 \b, [4-Scr]
#------------------------------------------------------------------------------
# gameboy: file(1) magic for the Nintendo (Color) Gameboy raw ROM format
# game boy: file(1) magic for the Nintendo (Color) Game Boy raw ROM format
#
0x104 belong 0xCEED6666 Gameboy ROM:
0x104 belong 0xCEED6666 Game Boy ROM:
>0x134 string >\0 "%.16s"
>0x146 byte 0x03 \b,[SGB]
>0x147 byte 0x00 \b, [ROM ONLY]
@ -4605,8 +4605,8 @@
0 string \x01ZZZZZ\x01 3DO "Opera" file system
# From Gurkan Sengun <gurkan@linuks.mine.nu>, www.linuks.mine.nu
0 string GBS Nintendo Gameboy Music/Audio Data
12 string GameBoy\ Music\ Module Nintendo Gameboy Music Module
0 string GBS Nintendo Game Boy Music/Audio Data
12 string GameBoy\ Music\ Module Nintendo Game Boy Music Module
# Playstations Patch Files from: From: Thomas Klausner <tk@giga.or.at>
0 string PPF30 Playstation Patch File version 3.0
@ -15279,7 +15279,7 @@
# $File: oasis,v 1.1 2011/03/15 02:09:38 christos Exp $
# OASIS
# Summary: OASIS stream file
# Long descripton: Open Artwork System Interchange Standard
# Long description: Open Artwork System Interchange Standard
# File extension: .oas
# Full name: Ben Cowley (bcowley@broadcom.com)
# Philip Dixon (pdixon@broadcom.com)

View file

@ -44,6 +44,7 @@ static const filter_list_entry filter_list[] = {
{ "float", FILTER_VALIDATE_FLOAT, php_filter_float },
{ "validate_regexp", FILTER_VALIDATE_REGEXP, php_filter_validate_regexp },
{ "validate_domain", FILTER_VALIDATE_DOMAIN, php_filter_validate_domain },
{ "validate_url", FILTER_VALIDATE_URL, php_filter_validate_url },
{ "validate_email", FILTER_VALIDATE_EMAIL, php_filter_validate_email },
{ "validate_ip", FILTER_VALIDATE_IP, php_filter_validate_ip },
@ -231,6 +232,7 @@ PHP_MINIT_FUNCTION(filter)
REGISTER_LONG_CONSTANT("FILTER_VALIDATE_FLOAT", FILTER_VALIDATE_FLOAT, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("FILTER_VALIDATE_REGEXP", FILTER_VALIDATE_REGEXP, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("FILTER_VALIDATE_DOMAIN", FILTER_VALIDATE_DOMAIN, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("FILTER_VALIDATE_URL", FILTER_VALIDATE_URL, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("FILTER_VALIDATE_EMAIL", FILTER_VALIDATE_EMAIL, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("FILTER_VALIDATE_IP", FILTER_VALIDATE_IP, CONST_CS | CONST_PERSISTENT);
@ -278,6 +280,8 @@ PHP_MINIT_FUNCTION(filter)
REGISTER_LONG_CONSTANT("FILTER_FLAG_NO_RES_RANGE", FILTER_FLAG_NO_RES_RANGE, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("FILTER_FLAG_NO_PRIV_RANGE", FILTER_FLAG_NO_PRIV_RANGE, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("FILTER_FLAG_HOSTNAME", FILTER_FLAG_HOSTNAME, CONST_CS | CONST_PERSISTENT);
sapi_register_input_filter(php_sapi_filter, php_sapi_filter_init TSRMLS_CC);
return SUCCESS;
@ -760,7 +764,7 @@ PHP_FUNCTION(filter_input)
/* }}} */
/* {{{ proto mixed filter_var(mixed variable [, long filter [, mixed options]])
* Returns the filtered version of the vriable.
* Returns the filtered version of the variable.
*/
PHP_FUNCTION(filter_var)
{

View file

@ -55,6 +55,8 @@
#define FILTER_FLAG_NO_RES_RANGE 0x400000
#define FILTER_FLAG_NO_PRIV_RANGE 0x800000
#define FILTER_FLAG_HOSTNAME 0x100000
#define FILTER_VALIDATE_INT 0x0101
#define FILTER_VALIDATE_BOOLEAN 0x0102
#define FILTER_VALIDATE_FLOAT 0x0103
@ -64,7 +66,8 @@
#define FILTER_VALIDATE_EMAIL 0x0112
#define FILTER_VALIDATE_IP 0x0113
#define FILTER_VALIDATE_MAC 0x0114
#define FILTER_VALIDATE_LAST 0x0114
#define FILTER_VALIDATE_DOMAIN 0x0115
#define FILTER_VALIDATE_LAST 0x0115
#define FILTER_VALIDATE_ALL 0x0100

View file

@ -14,6 +14,7 @@
+----------------------------------------------------------------------+
| Authors: Derick Rethans <derick@php.net> |
| Pierre-A. Joye <pierre@php.net> |
| Kévin Dunglas <dunglas@gmail.com> |
+----------------------------------------------------------------------+
*/
@ -80,6 +81,8 @@
#define FORMAT_IPV4 4
#define FORMAT_IPV6 6
static int _php_filter_validate_ipv6(char *str, size_t str_len TSRMLS_DC);
static int php_filter_parse_int(const char *str, size_t str_len, zend_long *ret TSRMLS_DC) { /* {{{ */
zend_long ctx_value;
int sign = 0, digit = 0;
@ -452,6 +455,65 @@ void php_filter_validate_regexp(PHP_INPUT_FILTER_PARAM_DECL) /* {{{ */
RETURN_VALIDATION_FAILED
}
}
static int _php_filter_validate_domain(char * domain, int len, zend_long flags) /* {{{ */
{
char *e, *s, *t;
size_t l;
int hostname = flags & FILTER_FLAG_HOSTNAME;
unsigned char i = 1;
s = domain;
l = len;
e = domain + l;
t = e - 1;
/* Ignore trailing dot */
if (*t == '.') {
e = t;
l--;
}
/* The total length cannot exceed 253 characters (final dot not included) */
if (l > 253) {
return 0;
}
/* First char must be alphanumeric */
if(*s == '.' || (hostname && !isalnum((int)*(unsigned char *)s))) {
return 0;
}
while (s < e) {
if (*s == '.') {
/* The first and the last character of a label must be alphanumeric */
if (*(s + 1) == '.' || (hostname && (!isalnum((int)*(unsigned char *)(s - 1)) || !isalnum((int)*(unsigned char *)(s + 1))))) {
return 0;
}
/* Reset label length counter */
i = 1;
} else {
if (i > 63 || (hostname && *s != '-' && !isalnum((int)*(unsigned char *)s))) {
return 0;
}
i++;
}
s++;
}
return 1;
}
/* }}} */
void php_filter_validate_domain(PHP_INPUT_FILTER_PARAM_DECL) /* {{{ */
{
if (!_php_filter_validate_domain(Z_STRVAL_P(value), Z_STRLEN_P(value), flags)) {
RETURN_VALIDATION_FAILED
}
}
/* }}} */
void php_filter_validate_url(PHP_INPUT_FILTER_PARAM_DECL) /* {{{ */
@ -473,25 +535,28 @@ void php_filter_validate_url(PHP_INPUT_FILTER_PARAM_DECL) /* {{{ */
}
if (url->scheme != NULL && (!strcasecmp(url->scheme, "http") || !strcasecmp(url->scheme, "https"))) {
char *e, *s;
char *e, *s, *t;
size_t l;
if (url->host == NULL) {
goto bad_url;
}
e = url->host + strlen(url->host);
s = url->host;
l = strlen(s);
e = url->host + l;
t = e - 1;
/* First char of hostname must be alphanumeric */
if(!isalnum((int)*(unsigned char *)s)) {
goto bad_url;
/* An IPv6 enclosed by square brackets is a valid hostname */
if (*s == '[' && *t == ']' && _php_filter_validate_ipv6((s + 1), l - 2 TSRMLS_CC)) {
php_url_free(url);
return;
}
while (s < e) {
if (!isalnum((int)*(unsigned char *)s) && *s != '-' && *s != '.') {
goto bad_url;
}
s++;
// Validate domain
if (!_php_filter_validate_domain(url->host, l, FILTER_FLAG_HOSTNAME)) {
php_url_free(url);
RETURN_VALIDATION_FAILED
}
}

View file

@ -75,6 +75,7 @@ void php_filter_int(PHP_INPUT_FILTER_PARAM_DECL);
void php_filter_boolean(PHP_INPUT_FILTER_PARAM_DECL);
void php_filter_float(PHP_INPUT_FILTER_PARAM_DECL);
void php_filter_validate_regexp(PHP_INPUT_FILTER_PARAM_DECL);
void php_filter_validate_domain(PHP_INPUT_FILTER_PARAM_DECL);
void php_filter_validate_url(PHP_INPUT_FILTER_PARAM_DECL);
void php_filter_validate_email(PHP_INPUT_FILTER_PARAM_DECL);
void php_filter_validate_ip(PHP_INPUT_FILTER_PARAM_DECL);

View file

@ -11,7 +11,7 @@ var_dump(filter_list(array()));
echo "Done\n";
?>
--EXPECTF--
array(20) {
array(21) {
[0]=>
string(3) "int"
[1]=>
@ -21,36 +21,38 @@ array(20) {
[3]=>
string(15) "validate_regexp"
[4]=>
string(12) "validate_url"
string(15) "validate_domain"
[5]=>
string(14) "validate_email"
string(12) "validate_url"
[6]=>
string(11) "validate_ip"
string(14) "validate_email"
[7]=>
string(12) "validate_mac"
string(11) "validate_ip"
[8]=>
string(6) "string"
string(12) "validate_mac"
[9]=>
string(8) "stripped"
string(6) "string"
[10]=>
string(7) "encoded"
string(8) "stripped"
[11]=>
string(13) "special_chars"
string(7) "encoded"
[12]=>
string(18) "full_special_chars"
string(13) "special_chars"
[13]=>
string(10) "unsafe_raw"
string(18) "full_special_chars"
[14]=>
string(5) "email"
string(10) "unsafe_raw"
[15]=>
string(3) "url"
string(5) "email"
[16]=>
string(10) "number_int"
string(3) "url"
[17]=>
string(12) "number_float"
string(10) "number_int"
[18]=>
string(12) "magic_quotes"
string(12) "number_float"
[19]=>
string(12) "magic_quotes"
[20]=>
string(8) "callback"
}

View file

@ -11,6 +11,22 @@ $values = Array(
'http://www.example/img/test.png',
'http://www.example/img/dir/',
'http://www.example/img/dir',
'http://www.thelongestdomainnameintheworldandthensomeandthensomemoreandmore.com/',
'http://toolongtoolongtoolongtoolongtoolongtoolongtoolongtoolongtoolongtoolong.com',
'http://eauBcFReEmjLcoZwI0RuONNnwU4H9r151juCaqTI5VeIP5jcYIqhx1lh5vV00l2rTs6y7hOp7rYw42QZiq6VIzjcYrRm8gFRMk9U9Wi1grL8Mr5kLVloYLthHgyA94QK3SaXCATklxgo6XvcbXIqAGG7U0KxTr8hJJU1p2ZQ2mXHmp4DhYP8N9SRuEKzaCPcSIcW7uj21jZqBigsLsNAXEzU8SPXZjmVQVtwQATPWeWyGW4GuJhjP4Q8o0.com',
'http://kDTvHt1PPDgX5EiP2MwiXjcoWNOhhTuOVAUWJ3TmpBYCC9QoJV114LMYrV3Zl58.kDTvHt1PPDgX5EiP2MwiXjcoWNOhhTuOVAUWJ3TmpBYCC9QoJV114LMYrV3Zl58.kDTvHt1PPDgX5EiP2MwiXjcoWNOhhTuOVAUWJ3TmpBYCC9QoJV114LMYrV3Zl58.CQ1oT5Uq3jJt6Uhy3VH9u3Gi5YhfZCvZVKgLlaXNFhVKB1zJxvunR7SJa.com.',
'http://kDTvHt1PPDgX5EiP2MwiXjcoWNOhhTuOVAUWJ3TmpBYCC9QoJV114LMYrV3Zl58R.example.com',
'http://[2001:0db8:0000:85a3:0000:0000:ac1f:8001]',
'http://[2001:db8:0:85a3:0:0:ac1f:8001]:123/me.html',
'http://[2001:db8:0:85a3::ac1f:8001]/',
'http://[::1]',
'http://cont-ains.h-yph-en-s.com',
'http://..com',
'http://a.-bc.com',
'http://ab.cd-.com',
'http://-.abc.com',
'http://abc.-.abc.com',
'http://underscore_.example.com',
'http//www.example/wrong/url/',
'http:/www.example',
'file:///tmp/test.c',
@ -56,6 +72,22 @@ string(32) "http://www.example.com/index.php"
string(31) "http://www.example/img/test.png"
string(27) "http://www.example/img/dir/"
string(26) "http://www.example/img/dir"
string(79) "http://www.thelongestdomainnameintheworldandthensomeandthensomemoreandmore.com/"
bool(false)
bool(false)
string(261) "http://kDTvHt1PPDgX5EiP2MwiXjcoWNOhhTuOVAUWJ3TmpBYCC9QoJV114LMYrV3Zl58.kDTvHt1PPDgX5EiP2MwiXjcoWNOhhTuOVAUWJ3TmpBYCC9QoJV114LMYrV3Zl58.kDTvHt1PPDgX5EiP2MwiXjcoWNOhhTuOVAUWJ3TmpBYCC9QoJV114LMYrV3Zl58.CQ1oT5Uq3jJt6Uhy3VH9u3Gi5YhfZCvZVKgLlaXNFhVKB1zJxvunR7SJa.com."
bool(false)
string(48) "http://[2001:0db8:0000:85a3:0000:0000:ac1f:8001]"
string(50) "http://[2001:db8:0:85a3:0:0:ac1f:8001]:123/me.html"
string(36) "http://[2001:db8:0:85a3::ac1f:8001]/"
string(12) "http://[::1]"
string(31) "http://cont-ains.h-yph-en-s.com"
bool(false)
bool(false)
bool(false)
bool(false)
bool(false)
bool(false)
bool(false)
bool(false)
string(18) "file:///tmp/test.c"

View file

@ -14,6 +14,7 @@ int 1 123
boolean 1
float 1 123
validate_regexp O'Henry
validate_domain PHP 1 foo@bar.com http://a.b.c 1.2.3.4 123 123abc<>() O'Henry 하퍼 aa:bb:cc:dd:ee:ff
validate_url http://a.b.c
validate_email foo@bar.com
validate_ip 1.2.3.4
@ -29,4 +30,4 @@ url PHP 1 foo@bar.com http://a.b.c 1.2.3.4 123 12
number_int 1 1234 123 123
number_float 1 1234 123 123
magic_quotes PHP 1 foo@bar.com http://a.b.c 1.2.3.4 123 123abc<>() O\'Henry 하퍼 aa:bb:cc:dd:ee:ff
callback PHP 1 FOO@BAR.COM HTTP://A.B.C 1.2.3.4 123 123ABC<>() O'HENRY 하퍼 AA:BB:CC:DD:EE:FF
callback PHP 1 FOO@BAR.COM HTTP://A.B.C 1.2.3.4 123 123ABC<>() O'HENRY 하퍼 AA:BB:CC:DD:EE:FF

68
ext/filter/tests/056.phpt Normal file
View file

@ -0,0 +1,68 @@
--TEST--
filter_var() and FILTER_VALIDATE_DOMAIN
--SKIPIF--
<?php if (!extension_loaded("filter")) die("skip"); ?>
--FILE--
<?php
$values = Array(
'example.com',
'www.thelongestdomainnameintheworldandthensomeandthensomemoreandmore.com',
'toolongtoolongtoolongtoolongtoolongtoolongtoolongtoolongtoolongtoolong.com',
'eauBcFReEmjLcoZwI0RuONNnwU4H9r151juCaqTI5VeIP5jcYIqhx1lh5vV00l2rTs6y7hOp7rYw42QZiq6VIzjcYrRm8gFRMk9U9Wi1grL8Mr5kLVloYLthHgyA94QK3SaXCATklxgo6XvcbXIqAGG7U0KxTr8hJJU1p2ZQ2mXHmp4DhYP8N9SRuEKzaCPcSIcW7uj21jZqBigsLsNAXEzU8SPXZjmVQVtwQATPWeWyGW4GuJhjP4Q8o0.com',
'kDTvHt1PPDgX5EiP2MwiXjcoWNOhhTuOVAUWJ3TmpBYCC9QoJV114LMYrV3Zl58.kDTvHt1PPDgX5EiP2MwiXjcoWNOhhTuOVAUWJ3TmpBYCC9QoJV114LMYrV3Zl58.kDTvHt1PPDgX5EiP2MwiXjcoWNOhhTuOVAUWJ3TmpBYCC9QoJV114LMYrV3Zl58.CQ1oT5Uq3jJt6Uhy3VH9u3Gi5YhfZCvZVKgLlaXNFhVKB1zJxvunR7SJa.com.',
'cont-ains.h-yph-en-s.com',
'..com',
'ab..cc.dd',
'a.-bc.com',
'ab.cd-.com',
'-.abc.com',
'abc.-.abc.com',
'underscore_.example.com',
'',
-1,
array(),
'\r\n',
);
foreach ($values as $value) {
var_dump(filter_var($value, FILTER_VALIDATE_DOMAIN, FILTER_FLAG_HOSTNAME));
}
var_dump(filter_var('_example.com', FILTER_VALIDATE_DOMAIN));
var_dump(filter_var('_example.com', FILTER_VALIDATE_DOMAIN, FILTER_FLAG_HOSTNAME));
var_dump(filter_var('test_.example.com', FILTER_VALIDATE_DOMAIN));
var_dump(filter_var('test_.example.com', FILTER_VALIDATE_DOMAIN, FILTER_FLAG_HOSTNAME));
var_dump(filter_var('te_st.example.com', FILTER_VALIDATE_DOMAIN));
var_dump(filter_var('te_st.example.com', FILTER_VALIDATE_DOMAIN, FILTER_FLAG_HOSTNAME));
var_dump(filter_var('test._example.com', FILTER_VALIDATE_DOMAIN));
var_dump(filter_var('test._example.com', FILTER_VALIDATE_DOMAIN, FILTER_FLAG_HOSTNAME));
echo "Done\n";
?>
--EXPECT--
string(11) "example.com"
string(71) "www.thelongestdomainnameintheworldandthensomeandthensomemoreandmore.com"
bool(false)
bool(false)
string(254) "kDTvHt1PPDgX5EiP2MwiXjcoWNOhhTuOVAUWJ3TmpBYCC9QoJV114LMYrV3Zl58.kDTvHt1PPDgX5EiP2MwiXjcoWNOhhTuOVAUWJ3TmpBYCC9QoJV114LMYrV3Zl58.kDTvHt1PPDgX5EiP2MwiXjcoWNOhhTuOVAUWJ3TmpBYCC9QoJV114LMYrV3Zl58.CQ1oT5Uq3jJt6Uhy3VH9u3Gi5YhfZCvZVKgLlaXNFhVKB1zJxvunR7SJa.com."
string(24) "cont-ains.h-yph-en-s.com"
bool(false)
bool(false)
bool(false)
bool(false)
bool(false)
bool(false)
bool(false)
bool(false)
bool(false)
bool(false)
bool(false)
string(12) "_example.com"
bool(false)
string(17) "test_.example.com"
bool(false)
string(17) "te_st.example.com"
bool(false)
string(17) "test._example.com"
bool(false)
Done

View file

@ -69,8 +69,8 @@ typedef struct ftpbuf
ftptype_t type; /* current transfer type */
int pasv; /* 0=off; 1=pasv; 2=ready */
php_sockaddr_storage pasvaddr; /* passive mode address */
zend_long timeout_sec; /* User configureable timeout (seconds) */
int autoseek; /* User configureable autoseek flag */
zend_long timeout_sec; /* User configurable timeout (seconds) */
int autoseek; /* User configurable autoseek flag */
int nb; /* "nonblocking" transfer in progress */
databuf_t *data; /* Data connection for "nonblocking" transfers */

View file

@ -782,7 +782,7 @@ int gdImageBrightness(gdImagePtr src, int brightness);
/* Set the contrast level <contrast> for the image <src> */
int gdImageContrast(gdImagePtr src, double contrast);
/* Simply adds or substracts respectively red, green or blue to a pixel */
/* Simply adds or subtracts respectively red, green or blue to a pixel */
int gdImageColor(gdImagePtr src, const int red, const int green, const int blue, const int alpha);
/* Image convolution by a 3x3 custom matrix */

View file

@ -1,6 +1,6 @@
/* This is potentially great stuff, but fails against the test
program at the end. This would probably be much more
efficent than the implementation currently in gd.c if the
efficient than the implementation currently in gd.c if the
errors in the output were corrected. TBB */
#if 0

View file

@ -464,7 +464,7 @@ static void *fontFetch (char **error, void *key)
return NULL;
}
/* FIXME - This mapping stuff is imcomplete - where is the spec? */
/* FIXME - This mapping stuff is incomplete - where is the spec? */
/* EAM - It's worse than that. It's pointless to match character encodings here.
* As currently written, the stored a->face->charmap only matches one of
* the actual charmaps and we cannot know at this stage if it is the right

Some files were not shown because too many files have changed in this diff Show more