Merge remote-tracking branch 'origin/master' into native-tls

* origin/master: (214 commits)
  fix datatype mismatch warnings
  fix datatype mismatches
  fix datatype mismatches
  fix datatype mismatches
  fix datatype mismatch warnings
  fix datatype mismatch warnings
  fix datatype mismatch warnings
  fix datatype mismatch warning
  fix datatype mismatches
  fix datatype mismatch warnings
  Re-add phpdbg to travis
  Added some NEWS
  Make xml valid (missing space between attrs)
  Fix info classes file name in xml
  Add note about <eval> tag for errors in xml.md
  Name the tag <eval> if the error id during ev cmd
  Do not print out xml as PHP print...
  Fix output to wrong function
  Fixed parameter order on %.*s
  Too much copypaste...
  ...
This commit is contained in:
Anatol Belski 2014-10-24 22:28:32 +02:00
commit c51a42076c
156 changed files with 10662 additions and 6350 deletions

View file

@ -47,3 +47,4 @@ before_script:
# Run PHPs run-tests.php
script:
- ./sapi/cli/php run-tests.php -p `pwd`/sapi/cli/php -g "FAIL,XFAIL,BORK,WARN,LEAK,SKIP" --show-diff --set-timeout 120
- ./sapi/cli/php sapi/phpdbg/tests/run-tests.php -diff2stdout --phpdbg sapi/phpdbg/phpdbg

24
Zend/tests/bug68262.phpt Normal file
View file

@ -0,0 +1,24 @@
--TEST--
Bug #68262: Broken reference across cloned objects
--FILE--
<?php
class C {
public $p;
}
$first = new C;
$first->p = 'init';
$clone = clone $first;
$ref =& $first->p;
unset($ref);
$clone = clone $first;
$clone->p = 'foo';
var_dump($first->p);
?>
--EXPECT--
string(4) "init"

View file

@ -224,13 +224,13 @@ ZEND_API int zend_make_printable_zval(zval *expr, zval *expr_copy TSRMLS_DC) /*
}
/* }}} */
ZEND_API int zend_print_zval(zval *expr, int indent TSRMLS_DC) /* {{{ */
ZEND_API size_t zend_print_zval(zval *expr, int indent TSRMLS_DC) /* {{{ */
{
return zend_print_zval_ex(zend_write, expr, indent TSRMLS_CC);
}
/* }}} */
ZEND_API int zend_print_zval_ex(zend_write_func_t write_func, zval *expr, int indent TSRMLS_DC) /* {{{ */
ZEND_API size_t zend_print_zval_ex(zend_write_func_t write_func, zval *expr, int indent TSRMLS_DC) /* {{{ */
{
zend_string *str = zval_get_string(expr);
size_t len = str->len;
@ -797,7 +797,7 @@ void zend_shutdown(TSRMLS_D) /* {{{ */
void zend_set_utility_values(zend_utility_values *utility_values) /* {{{ */
{
zend_uv = *utility_values;
zend_uv.import_use_extension_length = strlen(zend_uv.import_use_extension);
zend_uv.import_use_extension_length = (uint)strlen(zend_uv.import_use_extension);
}
/* }}} */
@ -831,11 +831,11 @@ ZEND_API void zend_append_version_info(const zend_extension *extension) /* {{{ *
char *new_info;
uint new_info_length;
new_info_length = sizeof(" with v, , by \n")
new_info_length = (uint)(sizeof(" with v, , by \n")
+ strlen(extension->name)
+ strlen(extension->version)
+ strlen(extension->copyright)
+ strlen(extension->author);
+ strlen(extension->author));
new_info = (char *) malloc(new_info_length + 1);
@ -1101,7 +1101,7 @@ static void zend_error_va_list(int type, const char *format, va_list args)
# endif
#endif
va_copy(usr_copy, args);
len = zend_vspprintf(&str, 0, format, usr_copy);
len = (int)zend_vspprintf(&str, 0, format, usr_copy);
ZVAL_NEW_STR(&params[1], zend_string_init(str, len, 0));
efree(str);
#ifdef va_copy

View file

@ -213,7 +213,7 @@ typedef struct _zend_utility_values {
zend_bool html_errors;
} zend_utility_values;
typedef int (*zend_write_func_t)(const char *str, uint str_length);
typedef int (*zend_write_func_t)(const char *str, size_t str_length);
#define zend_bailout() _zend_bailout(__FILE__, __LINE__)
@ -244,8 +244,8 @@ ZEND_API void _zend_bailout(char *filename, uint lineno);
ZEND_API char *get_zend_version(void);
ZEND_API int zend_make_printable_zval(zval *expr, zval *expr_copy TSRMLS_DC);
ZEND_API int zend_print_zval(zval *expr, int indent TSRMLS_DC);
ZEND_API int zend_print_zval_ex(zend_write_func_t write_func, zval *expr, int indent TSRMLS_DC);
ZEND_API size_t zend_print_zval(zval *expr, int indent TSRMLS_DC);
ZEND_API size_t zend_print_zval_ex(zend_write_func_t write_func, zval *expr, int indent TSRMLS_DC);
ZEND_API void zend_print_zval_r(zval *expr, int indent TSRMLS_DC);
ZEND_API void zend_print_flat_zval_r(zval *expr TSRMLS_DC);
ZEND_API void zend_print_zval_r_ex(zend_write_func_t write_func, zval *expr, int indent TSRMLS_DC);

View file

@ -1336,7 +1336,7 @@ ZEND_API int add_assoc_function(zval *arg, const char *key, void (*function_ptr)
}
/* }}} */
ZEND_API int add_assoc_long_ex(zval *arg, const char *key, uint key_len, zend_long n) /* {{{ */
ZEND_API int add_assoc_long_ex(zval *arg, const char *key, size_t key_len, zend_long n) /* {{{ */
{
zval *ret, tmp;
@ -1346,7 +1346,7 @@ ZEND_API int add_assoc_long_ex(zval *arg, const char *key, uint key_len, zend_lo
}
/* }}} */
ZEND_API int add_assoc_null_ex(zval *arg, const char *key, uint key_len) /* {{{ */
ZEND_API int add_assoc_null_ex(zval *arg, const char *key, size_t key_len) /* {{{ */
{
zval *ret, tmp;
@ -1356,7 +1356,7 @@ ZEND_API int add_assoc_null_ex(zval *arg, const char *key, uint key_len) /* {{{
}
/* }}} */
ZEND_API int add_assoc_bool_ex(zval *arg, const char *key, uint key_len, int b) /* {{{ */
ZEND_API int add_assoc_bool_ex(zval *arg, const char *key, size_t key_len, int b) /* {{{ */
{
zval *ret, tmp;
@ -1366,7 +1366,7 @@ ZEND_API int add_assoc_bool_ex(zval *arg, const char *key, uint key_len, int b)
}
/* }}} */
ZEND_API int add_assoc_resource_ex(zval *arg, const char *key, uint key_len, zend_resource *r) /* {{{ */
ZEND_API int add_assoc_resource_ex(zval *arg, const char *key, size_t key_len, zend_resource *r) /* {{{ */
{
zval *ret, tmp;
@ -1376,7 +1376,7 @@ ZEND_API int add_assoc_resource_ex(zval *arg, const char *key, uint key_len, zen
}
/* }}} */
ZEND_API int add_assoc_double_ex(zval *arg, const char *key, uint key_len, double d) /* {{{ */
ZEND_API int add_assoc_double_ex(zval *arg, const char *key, size_t key_len, double d) /* {{{ */
{
zval *ret, tmp;
@ -1386,7 +1386,7 @@ ZEND_API int add_assoc_double_ex(zval *arg, const char *key, uint key_len, doubl
}
/* }}} */
ZEND_API int add_assoc_str_ex(zval *arg, const char *key, uint key_len, zend_string *str) /* {{{ */
ZEND_API int add_assoc_str_ex(zval *arg, const char *key, size_t key_len, zend_string *str) /* {{{ */
{
zval *ret, tmp;
@ -1396,7 +1396,7 @@ ZEND_API int add_assoc_str_ex(zval *arg, const char *key, uint key_len, zend_str
}
/* }}} */
ZEND_API int add_assoc_string_ex(zval *arg, const char *key, uint key_len, char *str) /* {{{ */
ZEND_API int add_assoc_string_ex(zval *arg, const char *key, size_t key_len, char *str) /* {{{ */
{
zval *ret, tmp;
@ -1406,7 +1406,7 @@ ZEND_API int add_assoc_string_ex(zval *arg, const char *key, uint key_len, char
}
/* }}} */
ZEND_API int add_assoc_stringl_ex(zval *arg, const char *key, uint key_len, char *str, size_t length) /* {{{ */
ZEND_API int add_assoc_stringl_ex(zval *arg, const char *key, size_t key_len, char *str, size_t length) /* {{{ */
{
zval *ret, tmp;
@ -1416,7 +1416,7 @@ ZEND_API int add_assoc_stringl_ex(zval *arg, const char *key, uint key_len, char
}
/* }}} */
ZEND_API int add_assoc_zval_ex(zval *arg, const char *key, uint key_len, zval *value) /* {{{ */
ZEND_API int add_assoc_zval_ex(zval *arg, const char *key, size_t key_len, zval *value) /* {{{ */
{
zval *ret;
@ -1689,7 +1689,7 @@ ZEND_API int array_set_zval_key(HashTable *ht, zval *key, zval *value TSRMLS_DC)
}
/* }}} */
ZEND_API int add_property_long_ex(zval *arg, const char *key, uint key_len, zend_long n TSRMLS_DC) /* {{{ */
ZEND_API int add_property_long_ex(zval *arg, const char *key, size_t key_len, zend_long n TSRMLS_DC) /* {{{ */
{
zval tmp;
zval z_key;
@ -1703,7 +1703,7 @@ ZEND_API int add_property_long_ex(zval *arg, const char *key, uint key_len, zend
}
/* }}} */
ZEND_API int add_property_bool_ex(zval *arg, const char *key, uint key_len, zend_long b TSRMLS_DC) /* {{{ */
ZEND_API int add_property_bool_ex(zval *arg, const char *key, size_t key_len, zend_long b TSRMLS_DC) /* {{{ */
{
zval tmp;
zval z_key;
@ -1717,7 +1717,7 @@ ZEND_API int add_property_bool_ex(zval *arg, const char *key, uint key_len, zend
}
/* }}} */
ZEND_API int add_property_null_ex(zval *arg, const char *key, uint key_len TSRMLS_DC) /* {{{ */
ZEND_API int add_property_null_ex(zval *arg, const char *key, size_t key_len TSRMLS_DC) /* {{{ */
{
zval tmp;
zval z_key;
@ -1731,7 +1731,7 @@ ZEND_API int add_property_null_ex(zval *arg, const char *key, uint key_len TSRML
}
/* }}} */
ZEND_API int add_property_resource_ex(zval *arg, const char *key, uint key_len, zend_resource *r TSRMLS_DC) /* {{{ */
ZEND_API int add_property_resource_ex(zval *arg, const char *key, size_t key_len, zend_resource *r TSRMLS_DC) /* {{{ */
{
zval tmp;
zval z_key;
@ -1745,7 +1745,7 @@ ZEND_API int add_property_resource_ex(zval *arg, const char *key, uint key_len,
}
/* }}} */
ZEND_API int add_property_double_ex(zval *arg, const char *key, uint key_len, double d TSRMLS_DC) /* {{{ */
ZEND_API int add_property_double_ex(zval *arg, const char *key, size_t key_len, double d TSRMLS_DC) /* {{{ */
{
zval tmp;
zval z_key;
@ -1759,7 +1759,7 @@ ZEND_API int add_property_double_ex(zval *arg, const char *key, uint key_len, do
}
/* }}} */
ZEND_API int add_property_str_ex(zval *arg, const char *key, uint key_len, zend_string *str TSRMLS_DC) /* {{{ */
ZEND_API int add_property_str_ex(zval *arg, const char *key, size_t key_len, zend_string *str TSRMLS_DC) /* {{{ */
{
zval tmp;
zval z_key;
@ -1773,7 +1773,7 @@ ZEND_API int add_property_str_ex(zval *arg, const char *key, uint key_len, zend_
}
/* }}} */
ZEND_API int add_property_string_ex(zval *arg, const char *key, uint key_len, const char *str TSRMLS_DC) /* {{{ */
ZEND_API int add_property_string_ex(zval *arg, const char *key, size_t key_len, const char *str TSRMLS_DC) /* {{{ */
{
zval tmp;
zval z_key;
@ -1787,7 +1787,7 @@ ZEND_API int add_property_string_ex(zval *arg, const char *key, uint key_len, co
}
/* }}} */
ZEND_API int add_property_stringl_ex(zval *arg, const char *key, uint key_len, const char *str, size_t length TSRMLS_DC) /* {{{ */
ZEND_API int add_property_stringl_ex(zval *arg, const char *key, size_t key_len, const char *str, size_t length TSRMLS_DC) /* {{{ */
{
zval tmp;
zval z_key;
@ -1801,7 +1801,7 @@ ZEND_API int add_property_stringl_ex(zval *arg, const char *key, uint key_len, c
}
/* }}} */
ZEND_API int add_property_zval_ex(zval *arg, const char *key, uint key_len, zval *value TSRMLS_DC) /* {{{ */
ZEND_API int add_property_zval_ex(zval *arg, const char *key, size_t key_len, zval *value TSRMLS_DC) /* {{{ */
{
zval z_key;
@ -1814,7 +1814,7 @@ ZEND_API int add_property_zval_ex(zval *arg, const char *key, uint key_len, zval
ZEND_API int zend_startup_module_ex(zend_module_entry *module TSRMLS_DC) /* {{{ */
{
int name_len;
size_t name_len;
zend_string *lcname;
if (module->module_started) {
@ -2001,7 +2001,7 @@ ZEND_API void zend_destroy_modules(void) /* {{{ */
ZEND_API zend_module_entry* zend_register_module_ex(zend_module_entry *module TSRMLS_DC) /* {{{ */
{
int name_len;
size_t name_len;
zend_string *lcname;
zend_module_entry *module_ptr;
@ -2070,7 +2070,7 @@ ZEND_API zend_module_entry* zend_register_internal_module(zend_module_entry *mod
ZEND_API void zend_check_magic_method_implementation(const zend_class_entry *ce, const zend_function *fptr, int error_type TSRMLS_DC) /* {{{ */
{
char lcname[16];
int name_len;
size_t name_len;
/* we don't care if the function name is longer, in fact lowercasing only
* the beginning of the name speeds up the check process */
@ -2142,9 +2142,9 @@ ZEND_API int zend_register_functions(zend_class_entry *scope, const zend_functio
int error_type;
zend_function *ctor = NULL, *dtor = NULL, *clone = NULL, *__get = NULL, *__set = NULL, *__unset = NULL, *__isset = NULL, *__call = NULL, *__callstatic = NULL, *__tostring = NULL, *__debugInfo = NULL;
zend_string *lowercase_name;
int fname_len;
size_t fname_len;
const char *lc_class_name = NULL;
int class_name_len = 0;
size_t class_name_len = 0;
if (type==MODULE_PERSISTENT) {
error_type = E_CORE_WARNING;
@ -2417,7 +2417,7 @@ ZEND_API void zend_unregister_functions(const zend_function_entry *functions, in
int i=0;
HashTable *target_function_table = function_table;
zend_string *lowercase_name;
int fname_len;
size_t fname_len;
if (!target_function_table) {
target_function_table = CG(function_table);
@ -2699,7 +2699,7 @@ ZEND_API zend_class_entry *zend_register_internal_interface(zend_class_entry *or
}
/* }}} */
ZEND_API int zend_register_class_alias_ex(const char *name, int name_len, zend_class_entry *ce TSRMLS_DC) /* {{{ */
ZEND_API int zend_register_class_alias_ex(const char *name, size_t name_len, zend_class_entry *ce TSRMLS_DC) /* {{{ */
{
zend_string *lcname;
@ -2759,7 +2759,7 @@ static zend_function_entry disabled_function[] = {
ZEND_FE_END
};
ZEND_API int zend_disable_function(char *function_name, uint function_name_length TSRMLS_DC) /* {{{ */
ZEND_API int zend_disable_function(char *function_name, size_t function_name_length TSRMLS_DC) /* {{{ */
{
int ret;
@ -2792,7 +2792,7 @@ static const zend_function_entry disabled_class_new[] = {
ZEND_FE_END
};
ZEND_API int zend_disable_class(char *class_name, uint class_name_length TSRMLS_DC) /* {{{ */
ZEND_API int zend_disable_class(char *class_name, size_t class_name_length TSRMLS_DC) /* {{{ */
{
zend_class_entry *disabled_class;
zend_string *key;
@ -2814,7 +2814,7 @@ static int zend_is_callable_check_class(zend_string *name, zend_fcall_info_cache
{
int ret = 0;
zend_class_entry *ce;
int name_len = name->len;
size_t name_len = name->len;
zend_string *lcname;
ALLOCA_FLAG(use_heap);
@ -2893,7 +2893,7 @@ static int zend_is_callable_check_func(int check_flags, zval *callable, zend_fca
zend_string *mname, *cname;
zend_string *lmname;
const char *colon;
int clen, mlen;
size_t clen, mlen;
zend_class_entry *last_scope;
HashTable *ftable;
int call_via_handler = 0;
@ -3579,7 +3579,7 @@ ZEND_API int zend_fcall_info_call(zend_fcall_info *fci, zend_fcall_info_cache *f
ZEND_API const char *zend_get_module_version(const char *module_name) /* {{{ */
{
zend_string *lname;
int name_len = strlen(module_name);
size_t name_len = strlen(module_name);
zend_module_entry *module;
lname = zend_string_alloc(name_len, 0);
@ -3667,7 +3667,7 @@ ZEND_API int zend_declare_property_ex(zend_class_entry *ce, zend_string *name, z
}
/* }}} */
ZEND_API int zend_declare_property(zend_class_entry *ce, const char *name, int name_length, zval *property, int access_type TSRMLS_DC) /* {{{ */
ZEND_API int zend_declare_property(zend_class_entry *ce, const char *name, size_t name_length, zval *property, int access_type TSRMLS_DC) /* {{{ */
{
zend_string *key = zend_string_init(name, name_length, ce->type & ZEND_INTERNAL_CLASS);
int ret = zend_declare_property_ex(ce, key, property, access_type, NULL TSRMLS_CC);
@ -3676,7 +3676,7 @@ ZEND_API int zend_declare_property(zend_class_entry *ce, const char *name, int n
}
/* }}} */
ZEND_API int zend_declare_property_null(zend_class_entry *ce, const char *name, int name_length, int access_type TSRMLS_DC) /* {{{ */
ZEND_API int zend_declare_property_null(zend_class_entry *ce, const char *name, size_t name_length, int access_type TSRMLS_DC) /* {{{ */
{
zval property;
@ -3685,7 +3685,7 @@ ZEND_API int zend_declare_property_null(zend_class_entry *ce, const char *name,
}
/* }}} */
ZEND_API int zend_declare_property_bool(zend_class_entry *ce, const char *name, int name_length, zend_long value, int access_type TSRMLS_DC) /* {{{ */
ZEND_API int zend_declare_property_bool(zend_class_entry *ce, const char *name, size_t name_length, zend_long value, int access_type TSRMLS_DC) /* {{{ */
{
zval property;
@ -3694,7 +3694,7 @@ ZEND_API int zend_declare_property_bool(zend_class_entry *ce, const char *name,
}
/* }}} */
ZEND_API int zend_declare_property_long(zend_class_entry *ce, const char *name, int name_length, zend_long value, int access_type TSRMLS_DC) /* {{{ */
ZEND_API int zend_declare_property_long(zend_class_entry *ce, const char *name, size_t name_length, zend_long value, int access_type TSRMLS_DC) /* {{{ */
{
zval property;
@ -3703,7 +3703,7 @@ ZEND_API int zend_declare_property_long(zend_class_entry *ce, const char *name,
}
/* }}} */
ZEND_API int zend_declare_property_double(zend_class_entry *ce, const char *name, int name_length, double value, int access_type TSRMLS_DC) /* {{{ */
ZEND_API int zend_declare_property_double(zend_class_entry *ce, const char *name, size_t name_length, double value, int access_type TSRMLS_DC) /* {{{ */
{
zval property;
@ -3712,7 +3712,7 @@ ZEND_API int zend_declare_property_double(zend_class_entry *ce, const char *name
}
/* }}} */
ZEND_API int zend_declare_property_string(zend_class_entry *ce, const char *name, int name_length, const char *value, int access_type TSRMLS_DC) /* {{{ */
ZEND_API int zend_declare_property_string(zend_class_entry *ce, const char *name, size_t name_length, const char *value, int access_type TSRMLS_DC) /* {{{ */
{
zval property;
@ -3721,7 +3721,7 @@ ZEND_API int zend_declare_property_string(zend_class_entry *ce, const char *name
}
/* }}} */
ZEND_API int zend_declare_property_stringl(zend_class_entry *ce, const char *name, int name_length, const char *value, size_t value_len, int access_type TSRMLS_DC) /* {{{ */
ZEND_API int zend_declare_property_stringl(zend_class_entry *ce, const char *name, size_t name_length, const char *value, size_t value_len, int access_type TSRMLS_DC) /* {{{ */
{
zval property;
@ -3791,7 +3791,7 @@ ZEND_API int zend_declare_class_constant_string(zend_class_entry *ce, const char
}
/* }}} */
ZEND_API void zend_update_property(zend_class_entry *scope, zval *object, const char *name, int name_length, zval *value TSRMLS_DC) /* {{{ */
ZEND_API void zend_update_property(zend_class_entry *scope, zval *object, const char *name, size_t name_length, zval *value TSRMLS_DC) /* {{{ */
{
zval property;
zend_class_entry *old_scope = EG(scope);
@ -3809,7 +3809,7 @@ ZEND_API void zend_update_property(zend_class_entry *scope, zval *object, const
}
/* }}} */
ZEND_API void zend_update_property_null(zend_class_entry *scope, zval *object, const char *name, int name_length TSRMLS_DC) /* {{{ */
ZEND_API void zend_update_property_null(zend_class_entry *scope, zval *object, const char *name, size_t name_length TSRMLS_DC) /* {{{ */
{
zval tmp;
@ -3818,7 +3818,7 @@ ZEND_API void zend_update_property_null(zend_class_entry *scope, zval *object, c
}
/* }}} */
ZEND_API void zend_update_property_bool(zend_class_entry *scope, zval *object, const char *name, int name_length, zend_long value TSRMLS_DC) /* {{{ */
ZEND_API void zend_update_property_bool(zend_class_entry *scope, zval *object, const char *name, size_t name_length, zend_long value TSRMLS_DC) /* {{{ */
{
zval tmp;
@ -3827,7 +3827,7 @@ ZEND_API void zend_update_property_bool(zend_class_entry *scope, zval *object, c
}
/* }}} */
ZEND_API void zend_update_property_long(zend_class_entry *scope, zval *object, const char *name, int name_length, zend_long value TSRMLS_DC) /* {{{ */
ZEND_API void zend_update_property_long(zend_class_entry *scope, zval *object, const char *name, size_t name_length, zend_long value TSRMLS_DC) /* {{{ */
{
zval tmp;
@ -3836,7 +3836,7 @@ ZEND_API void zend_update_property_long(zend_class_entry *scope, zval *object, c
}
/* }}} */
ZEND_API void zend_update_property_double(zend_class_entry *scope, zval *object, const char *name, int name_length, double value TSRMLS_DC) /* {{{ */
ZEND_API void zend_update_property_double(zend_class_entry *scope, zval *object, const char *name, size_t name_length, double value TSRMLS_DC) /* {{{ */
{
zval tmp;
@ -3845,7 +3845,7 @@ ZEND_API void zend_update_property_double(zend_class_entry *scope, zval *object,
}
/* }}} */
ZEND_API void zend_update_property_str(zend_class_entry *scope, zval *object, const char *name, int name_length, zend_string *value TSRMLS_DC) /* {{{ */
ZEND_API void zend_update_property_str(zend_class_entry *scope, zval *object, const char *name, size_t name_length, zend_string *value TSRMLS_DC) /* {{{ */
{
zval tmp;
@ -3854,7 +3854,7 @@ ZEND_API void zend_update_property_str(zend_class_entry *scope, zval *object, co
}
/* }}} */
ZEND_API void zend_update_property_string(zend_class_entry *scope, zval *object, const char *name, int name_length, const char *value TSRMLS_DC) /* {{{ */
ZEND_API void zend_update_property_string(zend_class_entry *scope, zval *object, const char *name, size_t name_length, const char *value TSRMLS_DC) /* {{{ */
{
zval tmp;
@ -3864,7 +3864,7 @@ ZEND_API void zend_update_property_string(zend_class_entry *scope, zval *object,
}
/* }}} */
ZEND_API void zend_update_property_stringl(zend_class_entry *scope, zval *object, const char *name, int name_length, const char *value, size_t value_len TSRMLS_DC) /* {{{ */
ZEND_API void zend_update_property_stringl(zend_class_entry *scope, zval *object, const char *name, size_t name_length, const char *value, size_t value_len TSRMLS_DC) /* {{{ */
{
zval tmp;
@ -3874,7 +3874,7 @@ ZEND_API void zend_update_property_stringl(zend_class_entry *scope, zval *object
}
/* }}} */
ZEND_API int zend_update_static_property(zend_class_entry *scope, const char *name, int name_length, zval *value TSRMLS_DC) /* {{{ */
ZEND_API int zend_update_static_property(zend_class_entry *scope, const char *name, size_t name_length, zval *value TSRMLS_DC) /* {{{ */
{
zval *property;
zend_class_entry *old_scope = EG(scope);
@ -3913,7 +3913,7 @@ ZEND_API int zend_update_static_property(zend_class_entry *scope, const char *na
}
/* }}} */
ZEND_API int zend_update_static_property_null(zend_class_entry *scope, const char *name, int name_length TSRMLS_DC) /* {{{ */
ZEND_API int zend_update_static_property_null(zend_class_entry *scope, const char *name, size_t name_length TSRMLS_DC) /* {{{ */
{
zval tmp;
@ -3922,7 +3922,7 @@ ZEND_API int zend_update_static_property_null(zend_class_entry *scope, const cha
}
/* }}} */
ZEND_API int zend_update_static_property_bool(zend_class_entry *scope, const char *name, int name_length, zend_long value TSRMLS_DC) /* {{{ */
ZEND_API int zend_update_static_property_bool(zend_class_entry *scope, const char *name, size_t name_length, zend_long value TSRMLS_DC) /* {{{ */
{
zval tmp;
@ -3931,7 +3931,7 @@ ZEND_API int zend_update_static_property_bool(zend_class_entry *scope, const cha
}
/* }}} */
ZEND_API int zend_update_static_property_long(zend_class_entry *scope, const char *name, int name_length, zend_long value TSRMLS_DC) /* {{{ */
ZEND_API int zend_update_static_property_long(zend_class_entry *scope, const char *name, size_t name_length, zend_long value TSRMLS_DC) /* {{{ */
{
zval tmp;
@ -3940,7 +3940,7 @@ ZEND_API int zend_update_static_property_long(zend_class_entry *scope, const cha
}
/* }}} */
ZEND_API int zend_update_static_property_double(zend_class_entry *scope, const char *name, int name_length, double value TSRMLS_DC) /* {{{ */
ZEND_API int zend_update_static_property_double(zend_class_entry *scope, const char *name, size_t name_length, double value TSRMLS_DC) /* {{{ */
{
zval tmp;
@ -3949,7 +3949,7 @@ ZEND_API int zend_update_static_property_double(zend_class_entry *scope, const c
}
/* }}} */
ZEND_API int zend_update_static_property_string(zend_class_entry *scope, const char *name, int name_length, const char *value TSRMLS_DC) /* {{{ */
ZEND_API int zend_update_static_property_string(zend_class_entry *scope, const char *name, size_t name_length, const char *value TSRMLS_DC) /* {{{ */
{
zval tmp;
@ -3959,7 +3959,7 @@ ZEND_API int zend_update_static_property_string(zend_class_entry *scope, const c
}
/* }}} */
ZEND_API int zend_update_static_property_stringl(zend_class_entry *scope, const char *name, int name_length, const char *value, size_t value_len TSRMLS_DC) /* {{{ */
ZEND_API int zend_update_static_property_stringl(zend_class_entry *scope, const char *name, size_t name_length, const char *value, size_t value_len TSRMLS_DC) /* {{{ */
{
zval tmp;
@ -3969,7 +3969,7 @@ ZEND_API int zend_update_static_property_stringl(zend_class_entry *scope, const
}
/* }}} */
ZEND_API zval *zend_read_property(zend_class_entry *scope, zval *object, const char *name, int name_length, zend_bool silent TSRMLS_DC) /* {{{ */
ZEND_API zval *zend_read_property(zend_class_entry *scope, zval *object, const char *name, size_t name_length, zend_bool silent TSRMLS_DC) /* {{{ */
{
zval property, *value;
zend_class_entry *old_scope = EG(scope);
@ -3990,7 +3990,7 @@ ZEND_API zval *zend_read_property(zend_class_entry *scope, zval *object, const c
}
/* }}} */
ZEND_API zval *zend_read_static_property(zend_class_entry *scope, const char *name, int name_length, zend_bool silent TSRMLS_DC) /* {{{ */
ZEND_API zval *zend_read_static_property(zend_class_entry *scope, const char *name, size_t name_length, zend_bool silent TSRMLS_DC) /* {{{ */
{
zval *property;
zend_class_entry *old_scope = EG(scope);

View file

@ -276,15 +276,15 @@ ZEND_API zend_class_entry *zend_register_internal_class_ex(zend_class_entry *cla
ZEND_API zend_class_entry *zend_register_internal_interface(zend_class_entry *orig_class_entry TSRMLS_DC);
ZEND_API void zend_class_implements(zend_class_entry *class_entry TSRMLS_DC, int num_interfaces, ...);
ZEND_API int zend_register_class_alias_ex(const char *name, int name_len, zend_class_entry *ce TSRMLS_DC);
ZEND_API int zend_register_class_alias_ex(const char *name, size_t name_len, zend_class_entry *ce TSRMLS_DC);
#define zend_register_class_alias(name, ce) \
zend_register_class_alias_ex(name, sizeof(name)-1, ce TSRMLS_CC)
#define zend_register_ns_class_alias(ns, name, ce) \
zend_register_class_alias_ex(ZEND_NS_NAME(ns, name), sizeof(ZEND_NS_NAME(ns, name))-1, ce TSRMLS_CC)
ZEND_API int zend_disable_function(char *function_name, uint function_name_length TSRMLS_DC);
ZEND_API int zend_disable_class(char *class_name, uint class_name_length TSRMLS_DC);
ZEND_API int zend_disable_function(char *function_name, size_t function_name_length TSRMLS_DC);
ZEND_API int zend_disable_class(char *class_name, size_t class_name_length TSRMLS_DC);
ZEND_API void zend_wrong_param_count(TSRMLS_D);
@ -301,13 +301,13 @@ ZEND_API zend_bool zend_make_callable(zval *callable, zend_string **callable_nam
ZEND_API const char *zend_get_module_version(const char *module_name);
ZEND_API int zend_get_module_started(const char *module_name);
ZEND_API int zend_declare_property_ex(zend_class_entry *ce, zend_string *name, zval *property, int access_type, zend_string *doc_comment TSRMLS_DC);
ZEND_API int zend_declare_property(zend_class_entry *ce, const char *name, int name_length, zval *property, int access_type TSRMLS_DC);
ZEND_API int zend_declare_property_null(zend_class_entry *ce, const char *name, int name_length, int access_type TSRMLS_DC);
ZEND_API int zend_declare_property_bool(zend_class_entry *ce, const char *name, int name_length, zend_long value, int access_type TSRMLS_DC);
ZEND_API int zend_declare_property_long(zend_class_entry *ce, const char *name, int name_length, zend_long value, int access_type TSRMLS_DC);
ZEND_API int zend_declare_property_double(zend_class_entry *ce, const char *name, int name_length, double value, int access_type TSRMLS_DC);
ZEND_API int zend_declare_property_string(zend_class_entry *ce, const char *name, int name_length, const char *value, int access_type TSRMLS_DC);
ZEND_API int zend_declare_property_stringl(zend_class_entry *ce, const char *name, int name_length, const char *value, size_t value_len, int access_type TSRMLS_DC);
ZEND_API int zend_declare_property(zend_class_entry *ce, const char *name, size_t name_length, zval *property, int access_type TSRMLS_DC);
ZEND_API int zend_declare_property_null(zend_class_entry *ce, const char *name, size_t name_length, int access_type TSRMLS_DC);
ZEND_API int zend_declare_property_bool(zend_class_entry *ce, const char *name, size_t name_length, zend_long value, int access_type TSRMLS_DC);
ZEND_API int zend_declare_property_long(zend_class_entry *ce, const char *name, size_t name_length, zend_long value, int access_type TSRMLS_DC);
ZEND_API int zend_declare_property_double(zend_class_entry *ce, const char *name, size_t name_length, double value, int access_type TSRMLS_DC);
ZEND_API int zend_declare_property_string(zend_class_entry *ce, const char *name, size_t name_length, const char *value, int access_type TSRMLS_DC);
ZEND_API int zend_declare_property_stringl(zend_class_entry *ce, const char *name, size_t name_length, const char *value, size_t value_len, int access_type TSRMLS_DC);
ZEND_API int zend_declare_class_constant(zend_class_entry *ce, const char *name, size_t name_length, zval *value TSRMLS_DC);
ZEND_API int zend_declare_class_constant_null(zend_class_entry *ce, const char *name, size_t name_length TSRMLS_DC);
@ -318,26 +318,26 @@ ZEND_API int zend_declare_class_constant_stringl(zend_class_entry *ce, const cha
ZEND_API int zend_declare_class_constant_string(zend_class_entry *ce, const char *name, size_t name_length, const char *value TSRMLS_DC);
ZEND_API void zend_update_class_constants(zend_class_entry *class_type TSRMLS_DC);
ZEND_API void zend_update_property(zend_class_entry *scope, zval *object, const char *name, int name_length, zval *value TSRMLS_DC);
ZEND_API void zend_update_property_null(zend_class_entry *scope, zval *object, const char *name, int name_length TSRMLS_DC);
ZEND_API void zend_update_property_bool(zend_class_entry *scope, zval *object, const char *name, int name_length, zend_long value TSRMLS_DC);
ZEND_API void zend_update_property_long(zend_class_entry *scope, zval *object, const char *name, int name_length, zend_long value TSRMLS_DC);
ZEND_API void zend_update_property_double(zend_class_entry *scope, zval *object, const char *name, int name_length, double value TSRMLS_DC);
ZEND_API void zend_update_property_str(zend_class_entry *scope, zval *object, const char *name, int name_length, zend_string *value TSRMLS_DC);
ZEND_API void zend_update_property_string(zend_class_entry *scope, zval *object, const char *name, int name_length, const char *value TSRMLS_DC);
ZEND_API void zend_update_property_stringl(zend_class_entry *scope, zval *object, const char *name, int name_length, const char *value, size_t value_length TSRMLS_DC);
ZEND_API void zend_update_property(zend_class_entry *scope, zval *object, const char *name, size_t name_length, zval *value TSRMLS_DC);
ZEND_API void zend_update_property_null(zend_class_entry *scope, zval *object, const char *name, size_t name_length TSRMLS_DC);
ZEND_API void zend_update_property_bool(zend_class_entry *scope, zval *object, const char *name, size_t name_length, zend_long value TSRMLS_DC);
ZEND_API void zend_update_property_long(zend_class_entry *scope, zval *object, const char *name, size_t name_length, zend_long value TSRMLS_DC);
ZEND_API void zend_update_property_double(zend_class_entry *scope, zval *object, const char *name, size_t name_length, double value TSRMLS_DC);
ZEND_API void zend_update_property_str(zend_class_entry *scope, zval *object, const char *name, size_t name_length, zend_string *value TSRMLS_DC);
ZEND_API void zend_update_property_string(zend_class_entry *scope, zval *object, const char *name, size_t name_length, const char *value TSRMLS_DC);
ZEND_API void zend_update_property_stringl(zend_class_entry *scope, zval *object, const char *name, size_t name_length, const char *value, size_t value_length TSRMLS_DC);
ZEND_API int zend_update_static_property(zend_class_entry *scope, const char *name, int name_length, zval *value TSRMLS_DC);
ZEND_API int zend_update_static_property_null(zend_class_entry *scope, const char *name, int name_length TSRMLS_DC);
ZEND_API int zend_update_static_property_bool(zend_class_entry *scope, const char *name, int name_length, zend_long value TSRMLS_DC);
ZEND_API int zend_update_static_property_long(zend_class_entry *scope, const char *name, int name_length, zend_long value TSRMLS_DC);
ZEND_API int zend_update_static_property_double(zend_class_entry *scope, const char *name, int name_length, double value TSRMLS_DC);
ZEND_API int zend_update_static_property_string(zend_class_entry *scope, const char *name, int name_length, const char *value TSRMLS_DC);
ZEND_API int zend_update_static_property_stringl(zend_class_entry *scope, const char *name, int name_length, const char *value, size_t value_length TSRMLS_DC);
ZEND_API int zend_update_static_property(zend_class_entry *scope, const char *name, size_t name_length, zval *value TSRMLS_DC);
ZEND_API int zend_update_static_property_null(zend_class_entry *scope, const char *name, size_t name_length TSRMLS_DC);
ZEND_API int zend_update_static_property_bool(zend_class_entry *scope, const char *name, size_t name_length, zend_long value TSRMLS_DC);
ZEND_API int zend_update_static_property_long(zend_class_entry *scope, const char *name, size_t name_length, zend_long value TSRMLS_DC);
ZEND_API int zend_update_static_property_double(zend_class_entry *scope, const char *name, size_t name_length, double value TSRMLS_DC);
ZEND_API int zend_update_static_property_string(zend_class_entry *scope, const char *name, size_t name_length, const char *value TSRMLS_DC);
ZEND_API int zend_update_static_property_stringl(zend_class_entry *scope, const char *name, size_t name_length, const char *value, size_t value_length TSRMLS_DC);
ZEND_API zval *zend_read_property(zend_class_entry *scope, zval *object, const char *name, int name_length, zend_bool silent TSRMLS_DC);
ZEND_API zval *zend_read_property(zend_class_entry *scope, zval *object, const char *name, size_t name_length, zend_bool silent TSRMLS_DC);
ZEND_API zval *zend_read_static_property(zend_class_entry *scope, const char *name, int name_length, zend_bool silent TSRMLS_DC);
ZEND_API zval *zend_read_static_property(zend_class_entry *scope, const char *name, size_t name_length, zend_bool silent TSRMLS_DC);
ZEND_API char *zend_get_type_by_const(int type);
@ -373,15 +373,15 @@ ZEND_API void zend_merge_properties(zval *obj, HashTable *properties TSRMLS_DC);
/* no longer supported */
ZEND_API int add_assoc_function(zval *arg, const char *key, void (*function_ptr)(INTERNAL_FUNCTION_PARAMETERS));
ZEND_API int add_assoc_long_ex(zval *arg, const char *key, uint key_len, zend_long n);
ZEND_API int add_assoc_null_ex(zval *arg, const char *key, uint key_len);
ZEND_API int add_assoc_bool_ex(zval *arg, const char *key, uint key_len, int b);
ZEND_API int add_assoc_resource_ex(zval *arg, const char *key, uint key_len, zend_resource *r);
ZEND_API int add_assoc_double_ex(zval *arg, const char *key, uint key_len, double d);
ZEND_API int add_assoc_str_ex(zval *arg, const char *key, uint key_len, zend_string *str);
ZEND_API int add_assoc_string_ex(zval *arg, const char *key, uint key_len, char *str);
ZEND_API int add_assoc_stringl_ex(zval *arg, const char *key, uint key_len, char *str, size_t length);
ZEND_API int add_assoc_zval_ex(zval *arg, const char *key, uint key_len, zval *value);
ZEND_API int add_assoc_long_ex(zval *arg, const char *key, size_t key_len, zend_long n);
ZEND_API int add_assoc_null_ex(zval *arg, const char *key, size_t key_len);
ZEND_API int add_assoc_bool_ex(zval *arg, const char *key, size_t key_len, int b);
ZEND_API int add_assoc_resource_ex(zval *arg, const char *key, size_t key_len, zend_resource *r);
ZEND_API int add_assoc_double_ex(zval *arg, const char *key, size_t key_len, double d);
ZEND_API int add_assoc_str_ex(zval *arg, const char *key, size_t key_len, zend_string *str);
ZEND_API int add_assoc_string_ex(zval *arg, const char *key, size_t key_len, char *str);
ZEND_API int add_assoc_stringl_ex(zval *arg, const char *key, size_t key_len, char *str, size_t length);
ZEND_API int add_assoc_zval_ex(zval *arg, const char *key, size_t key_len, zval *value);
#define add_assoc_long(__arg, __key, __n) add_assoc_long_ex(__arg, __key, strlen(__key), __n)
#define add_assoc_null(__arg, __key) add_assoc_null_ex(__arg, __key, strlen(__key))
@ -433,15 +433,15 @@ ZEND_API zval *add_get_index_stringl(zval *arg, zend_ulong idx, const char *str,
ZEND_API int array_set_zval_key(HashTable *ht, zval *key, zval *value TSRMLS_DC);
ZEND_API int add_property_long_ex(zval *arg, const char *key, uint key_len, zend_long l TSRMLS_DC);
ZEND_API int add_property_null_ex(zval *arg, const char *key, uint key_len TSRMLS_DC);
ZEND_API int add_property_bool_ex(zval *arg, const char *key, uint key_len, zend_long b TSRMLS_DC);
ZEND_API int add_property_resource_ex(zval *arg, const char *key, uint key_len, zend_resource *r TSRMLS_DC);
ZEND_API int add_property_double_ex(zval *arg, const char *key, uint key_len, double d TSRMLS_DC);
ZEND_API int add_property_str_ex(zval *arg, const char *key, uint key_len, zend_string *str TSRMLS_DC);
ZEND_API int add_property_string_ex(zval *arg, const char *key, uint key_len, const char *str TSRMLS_DC);
ZEND_API int add_property_stringl_ex(zval *arg, const char *key, uint key_len, const char *str, size_t length TSRMLS_DC);
ZEND_API int add_property_zval_ex(zval *arg, const char *key, uint key_len, zval *value TSRMLS_DC);
ZEND_API int add_property_long_ex(zval *arg, const char *key, size_t key_len, zend_long l TSRMLS_DC);
ZEND_API int add_property_null_ex(zval *arg, const char *key, size_t key_len TSRMLS_DC);
ZEND_API int add_property_bool_ex(zval *arg, const char *key, size_t key_len, zend_long b TSRMLS_DC);
ZEND_API int add_property_resource_ex(zval *arg, const char *key, size_t key_len, zend_resource *r TSRMLS_DC);
ZEND_API int add_property_double_ex(zval *arg, const char *key, size_t key_len, double d TSRMLS_DC);
ZEND_API int add_property_str_ex(zval *arg, const char *key, size_t key_len, zend_string *str TSRMLS_DC);
ZEND_API int add_property_string_ex(zval *arg, const char *key, size_t key_len, const char *str TSRMLS_DC);
ZEND_API int add_property_stringl_ex(zval *arg, const char *key, size_t key_len, const char *str, size_t length TSRMLS_DC);
ZEND_API int add_property_zval_ex(zval *arg, const char *key, size_t key_len, zval *value TSRMLS_DC);
#define add_property_long(__arg, __key, __n) add_property_long_ex(__arg, __key, strlen(__key), __n TSRMLS_CC)
#define add_property_null(__arg, __key) add_property_null_ex(__arg, __key, strlen(__key) TSRMLS_CC)
@ -451,7 +451,7 @@ ZEND_API int add_property_zval_ex(zval *arg, const char *key, uint key_len, zval
#define add_property_str(__arg, __key, __str) add_property_str_ex(__arg, __key, strlen(__key), __str TSRMLS_CC)
#define add_property_string(__arg, __key, __str) add_property_string_ex(__arg, __key, strlen(__key), __str TSRMLS_CC)
#define add_property_stringl(__arg, __key, __str, __length) add_property_stringl_ex(__arg, __key, strlen(__key), __str, __length TSRMLS_CC)
#define add_property_zval(__arg, __key, __value) add_property_zval_ex(__arg, __key, strlen(__key), __value TSRMLS_CC)
#define add_property_zval(__arg, __key, __value) add_property_zval_ex(__arg, __key, strlen(__key), __value TSRMLS_CC)
ZEND_API int call_user_function(HashTable *function_table, zval *object, zval *function_name, zval *retval_ptr, uint32_t param_count, zval params[] TSRMLS_DC);

View file

@ -1028,7 +1028,7 @@ found:
static zend_always_inline void *zend_mm_alloc_large(zend_mm_heap *heap, size_t size ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC)
{
int pages_count = ZEND_MM_SIZE_TO_NUM(size, ZEND_MM_PAGE_SIZE);
int pages_count = (int)ZEND_MM_SIZE_TO_NUM(size, ZEND_MM_PAGE_SIZE);
#if ZEND_DEBUG
void *ptr = zend_mm_alloc_pages(heap, pages_count, size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC);
#else
@ -1261,7 +1261,7 @@ static zend_always_inline zend_mm_debug_info *zend_mm_get_debug_info(zend_mm_hea
ZEND_MM_CHECK(page_offset != 0, "zend_mm_heap corrupted");
chunk = (zend_mm_chunk*)ZEND_MM_ALIGNED_BASE(ptr, ZEND_MM_CHUNK_SIZE);
page_num = page_offset / ZEND_MM_PAGE_SIZE;
page_num = (int)(page_offset / ZEND_MM_PAGE_SIZE);
info = chunk->map[page_num];
ZEND_MM_CHECK(chunk->heap == heap, "zend_mm_heap corrupted");
if (EXPECTED(info & ZEND_MM_IS_SRUN)) {
@ -1326,7 +1326,7 @@ static zend_always_inline void zend_mm_free_heap(zend_mm_heap *heap, void *ptr Z
}
} else {
zend_mm_chunk *chunk = (zend_mm_chunk*)ZEND_MM_ALIGNED_BASE(ptr, ZEND_MM_CHUNK_SIZE);
int page_num = page_offset / ZEND_MM_PAGE_SIZE;
int page_num = (int)(page_offset / ZEND_MM_PAGE_SIZE);
zend_mm_page_info info = chunk->map[page_num];
ZEND_MM_CHECK(chunk->heap == heap, "zend_mm_heap corrupted");
@ -1357,7 +1357,7 @@ static size_t zend_mm_size(zend_mm_heap *heap, void *ptr ZEND_FILE_LINE_DC ZEND_
zend_mm_page_info info;
chunk = (zend_mm_chunk*)ZEND_MM_ALIGNED_BASE(ptr, ZEND_MM_CHUNK_SIZE);
page_num = page_offset / ZEND_MM_PAGE_SIZE;
page_num = (int)(page_offset / ZEND_MM_PAGE_SIZE);
info = chunk->map[page_num];
ZEND_MM_CHECK(chunk->heap == heap, "zend_mm_heap corrupted");
if (EXPECTED(info & ZEND_MM_IS_SRUN)) {
@ -1451,7 +1451,7 @@ static void *zend_mm_realloc_heap(zend_mm_heap *heap, void *ptr, size_t size ZEN
}
} else {
zend_mm_chunk *chunk = (zend_mm_chunk*)ZEND_MM_ALIGNED_BASE(ptr, ZEND_MM_CHUNK_SIZE);
int page_num = page_offset / ZEND_MM_PAGE_SIZE;
int page_num = (int)(page_offset / ZEND_MM_PAGE_SIZE);
zend_mm_page_info info = chunk->map[page_num];
#if ZEND_DEBUG
size_t real_size = size;
@ -1494,8 +1494,8 @@ static void *zend_mm_realloc_heap(zend_mm_heap *heap, void *ptr, size_t size ZEN
return ptr;
} else if (new_size < old_size) {
/* free tail pages */
int new_pages_count = new_size / ZEND_MM_PAGE_SIZE;
int rest_pages_count = (old_size - new_size) / ZEND_MM_PAGE_SIZE;
int new_pages_count = (int)(new_size / ZEND_MM_PAGE_SIZE);
int rest_pages_count = (int)((old_size - new_size) / ZEND_MM_PAGE_SIZE);
#if ZEND_MM_STAT
heap->size -= rest_pages_count * ZEND_MM_PAGE_SIZE;
@ -1513,8 +1513,8 @@ static void *zend_mm_realloc_heap(zend_mm_heap *heap, void *ptr, size_t size ZEN
#endif
return ptr;
} else /* if (new_size > old_size) */ {
int new_pages_count = new_size / ZEND_MM_PAGE_SIZE;
int old_pages_count = old_size / ZEND_MM_PAGE_SIZE;
int new_pages_count = (int)(new_size / ZEND_MM_PAGE_SIZE);
int old_pages_count = (int)(old_size / ZEND_MM_PAGE_SIZE);
/* try to allocate tail pages after this block */
if (page_num + new_pages_count <= ZEND_MM_PAGES &&

View file

@ -1059,7 +1059,7 @@ ZEND_FUNCTION(get_object_vars)
}
/* }}} */
static int same_name(const char *key, const char *name, uint32_t name_len) /* {{{ */
static int same_name(const char *key, const char *name, size_t name_len) /* {{{ */
{
char *lcname = zend_str_tolower_dup(name, name_len);
int ret = memcmp(lcname, key, name_len) == 0;
@ -1102,7 +1102,7 @@ ZEND_FUNCTION(get_class_methods)
zend_check_protected(mptr->common.scope, EG(scope)))
|| ((mptr->common.fn_flags & ZEND_ACC_PRIVATE) &&
EG(scope) == mptr->common.scope)))) {
uint len = mptr->common.function_name->len;
size_t len = mptr->common.function_name->len;
/* Do not display old-style inherited constructors */
if (!key) {

View file

@ -514,7 +514,7 @@ void zend_do_free(znode *op1 TSRMLS_DC) /* {{{ */
opline->result_type |= EXT_TYPE_UNUSED;
}
} else {
while (opline>CG(active_op_array)->opcodes) {
while (opline >= CG(active_op_array)->opcodes) {
if (opline->opcode == ZEND_FETCH_LIST &&
opline->op1_type == IS_VAR &&
opline->op1.var == op1->u.op.var) {
@ -1107,7 +1107,7 @@ ZEND_API zend_string *zend_mangle_property_name(const char *src1, size_t src1_le
}
/* }}} */
static int zend_strnlen(const char* s, size_t maxlen) /* {{{ */
static size_t zend_strnlen(const char* s, size_t maxlen) /* {{{ */
{
size_t len = 0;
while (*s++ && maxlen--) len++;
@ -1641,11 +1641,8 @@ static void zend_adjust_for_fetch_type(zend_op *opline, uint32_t type) /* {{{ */
case BP_VAR_R:
return;
case BP_VAR_W:
opline->opcode += 3;
return;
case BP_VAR_REF:
opline->opcode += 3;
opline->extended_value |= ZEND_FETCH_MAKE_REF;
return;
case BP_VAR_RW:
opline->opcode += 6;
@ -2281,8 +2278,6 @@ void zend_compile_assign(znode *result, zend_ast *ast TSRMLS_DC) /* {{{ */
opline->opcode = ZEND_ASSIGN_DIM;
opline = zend_emit_op_data(&expr_node TSRMLS_CC);
opline->op2.var = get_temporary_variable(CG(active_op_array));
opline->op2_type = IS_VAR;
return;
case ZEND_AST_PROP:
offset = zend_delayed_compile_begin(TSRMLS_C);
@ -2374,8 +2369,6 @@ void zend_compile_compound_assign(znode *result, zend_ast *ast TSRMLS_DC) /* {{{
opline->extended_value = ZEND_ASSIGN_DIM;
opline = zend_emit_op_data(&expr_node TSRMLS_CC);
opline->op2.var = get_temporary_variable(CG(active_op_array));
opline->op2_type = IS_VAR;
return;
case ZEND_AST_PROP:
offset = zend_delayed_compile_begin(TSRMLS_C);
@ -2944,10 +2937,23 @@ void zend_compile_new(znode *result, zend_ast *ast TSRMLS_DC) /* {{{ */
zend_op *opline;
uint32_t opnum;
zend_compile_class_ref(&class_node, class_ast TSRMLS_CC);
if (zend_is_const_default_class_ref(class_ast)) {
class_node.op_type = IS_CONST;
ZVAL_STR(&class_node.u.constant, zend_resolve_class_name_ast(class_ast TSRMLS_CC));
} else {
zend_compile_class_ref(&class_node, class_ast TSRMLS_CC);
}
opnum = get_next_op_number(CG(active_op_array));
zend_emit_op(result, ZEND_NEW, &class_node, NULL TSRMLS_CC);
opline = zend_emit_op(result, ZEND_NEW, NULL, NULL TSRMLS_CC);
if (class_node.op_type == IS_CONST) {
opline->op1_type = IS_CONST;
opline->op1.constant = zend_add_class_name_literal(
CG(active_op_array), Z_STR(class_node.u.constant) TSRMLS_CC);
} else {
SET_NODE(opline->op1, &class_node);
}
zend_compile_call_common(&ctor_result, args_ast, NULL TSRMLS_CC);
zend_do_free(&ctor_result TSRMLS_CC);
@ -3125,7 +3131,7 @@ void zend_compile_return(zend_ast *ast TSRMLS_DC) /* {{{ */
if (expr_ast) {
if (zend_is_call(expr_ast)) {
opline->extended_value = ZEND_RETURNS_FUNCTION;
} else if (!zend_is_variable(expr_ast)) {
} else if (by_ref && !zend_is_variable(expr_ast)) {
opline->extended_value = ZEND_RETURNS_VALUE;
}
}
@ -3812,7 +3818,7 @@ void zend_compile_params(zend_ast *ast TSRMLS_DC) /* {{{ */
arg_info = &arg_infos[i];
arg_info->name = estrndup(name->val, name->len);
arg_info->name_len = name->len;
arg_info->name_len = (uint32_t)name->len;
arg_info->pass_by_reference = is_ref;
arg_info->is_variadic = is_variadic;
arg_info->type_hint = 0;
@ -3856,7 +3862,7 @@ void zend_compile_params(zend_ast *ast TSRMLS_DC) /* {{{ */
arg_info->type_hint = IS_OBJECT;
arg_info->class_name = estrndup(class_name->val, class_name->len);
arg_info->class_name_len = class_name->len;
arg_info->class_name_len = (uint32_t)class_name->len;
zend_string_release(class_name);
@ -4389,7 +4395,6 @@ void zend_compile_use_trait(zend_ast *ast TSRMLS_DC) /* {{{ */
opline = get_next_op(CG(active_op_array) TSRMLS_CC);
opline->opcode = ZEND_ADD_TRAIT;
SET_NODE(opline->op1, &CG(implementing_class));
opline->extended_value = ZEND_FETCH_CLASS_TRAIT;
opline->op2_type = IS_CONST;
opline->op2.constant = zend_add_class_name_literal(CG(active_op_array),
zend_resolve_class_name_ast(trait_ast TSRMLS_CC) TSRMLS_CC);
@ -4438,7 +4443,6 @@ void zend_compile_implements(znode *class_node, zend_ast *ast TSRMLS_DC) /* {{{
}
opline = zend_emit_op(NULL, ZEND_ADD_INTERFACE, class_node, NULL TSRMLS_CC);
opline->extended_value = ZEND_FETCH_CLASS_INTERFACE;
opline->op2_type = IS_CONST;
opline->op2.constant = zend_add_class_name_literal(CG(active_op_array),
zend_resolve_class_name_ast(class_ast TSRMLS_CC) TSRMLS_CC);
@ -5420,10 +5424,23 @@ void zend_compile_instanceof(znode *result, zend_ast *ast TSRMLS_DC) /* {{{ */
"instanceof expects an object instance, constant given");
}
opline = zend_compile_class_ref(&class_node, class_ast TSRMLS_CC);
opline->extended_value |= ZEND_FETCH_CLASS_NO_AUTOLOAD;
if (zend_is_const_default_class_ref(class_ast)) {
class_node.op_type = IS_CONST;
ZVAL_STR(&class_node.u.constant, zend_resolve_class_name_ast(class_ast TSRMLS_CC));
} else {
opline = zend_compile_class_ref(&class_node, class_ast TSRMLS_CC);
opline->extended_value |= ZEND_FETCH_CLASS_NO_AUTOLOAD;
}
zend_emit_op_tmp(result, ZEND_INSTANCEOF, &obj_node, &class_node TSRMLS_CC);
opline = zend_emit_op_tmp(result, ZEND_INSTANCEOF, &obj_node, NULL TSRMLS_CC);
if (class_node.op_type == IS_CONST) {
opline->op2_type = IS_CONST;
opline->op2.constant = zend_add_class_name_literal(
CG(active_op_array), Z_STR(class_node.u.constant) TSRMLS_CC);
} else {
SET_NODE(opline->op2, &class_node);
}
}
/* }}} */

View file

@ -619,7 +619,6 @@ int zend_add_literal(zend_op_array *op_array, zval *zv TSRMLS_DC);
#define ZEND_FETCH_TYPE_MASK 0x70000000
#define ZEND_FETCH_STANDARD 0x00000000
#define ZEND_FETCH_MAKE_REF 0x04000000
#define ZEND_ISSET 0x02000000
#define ZEND_ISEMPTY 0x01000000

View file

@ -161,7 +161,7 @@ void clean_non_persistent_constants(TSRMLS_D)
}
}
ZEND_API void zend_register_null_constant(const char *name, uint name_len, int flags, int module_number TSRMLS_DC)
ZEND_API void zend_register_null_constant(const char *name, size_t name_len, int flags, int module_number TSRMLS_DC)
{
zend_constant c;
@ -172,7 +172,7 @@ ZEND_API void zend_register_null_constant(const char *name, uint name_len, int f
zend_register_constant(&c TSRMLS_CC);
}
ZEND_API void zend_register_bool_constant(const char *name, uint name_len, zend_bool bval, int flags, int module_number TSRMLS_DC)
ZEND_API void zend_register_bool_constant(const char *name, size_t name_len, zend_bool bval, int flags, int module_number TSRMLS_DC)
{
zend_constant c;
@ -183,7 +183,7 @@ ZEND_API void zend_register_bool_constant(const char *name, uint name_len, zend_
zend_register_constant(&c TSRMLS_CC);
}
ZEND_API void zend_register_long_constant(const char *name, uint name_len, zend_long lval, int flags, int module_number TSRMLS_DC)
ZEND_API void zend_register_long_constant(const char *name, size_t name_len, zend_long lval, int flags, int module_number TSRMLS_DC)
{
zend_constant c;
@ -195,7 +195,7 @@ ZEND_API void zend_register_long_constant(const char *name, uint name_len, zend_
}
ZEND_API void zend_register_double_constant(const char *name, uint name_len, double dval, int flags, int module_number TSRMLS_DC)
ZEND_API void zend_register_double_constant(const char *name, size_t name_len, double dval, int flags, int module_number TSRMLS_DC)
{
zend_constant c;
@ -207,7 +207,7 @@ ZEND_API void zend_register_double_constant(const char *name, uint name_len, dou
}
ZEND_API void zend_register_stringl_constant(const char *name, uint name_len, char *strval, uint strlen, int flags, int module_number TSRMLS_DC)
ZEND_API void zend_register_stringl_constant(const char *name, size_t name_len, char *strval, size_t strlen, int flags, int module_number TSRMLS_DC)
{
zend_constant c;
@ -219,12 +219,12 @@ ZEND_API void zend_register_stringl_constant(const char *name, uint name_len, ch
}
ZEND_API void zend_register_string_constant(const char *name, uint name_len, char *strval, int flags, int module_number TSRMLS_DC)
ZEND_API void zend_register_string_constant(const char *name, size_t name_len, char *strval, int flags, int module_number TSRMLS_DC)
{
zend_register_stringl_constant(name, name_len, strval, strlen(strval), flags, module_number TSRMLS_CC);
}
static zend_constant *zend_get_special_constant(const char *name, uint name_len TSRMLS_DC)
static zend_constant *zend_get_special_constant(const char *name, size_t name_len TSRMLS_DC)
{
zend_constant *c;
static char haltoff[] = "__COMPILER_HALT_OFFSET__";
@ -236,7 +236,7 @@ static zend_constant *zend_get_special_constant(const char *name, uint name_len
/* Returned constants may be cached, so they have to be stored */
if (EG(scope) && EG(scope)->name) {
int const_name_len;
size_t const_name_len;
zend_string *const_name;
const_name_len = sizeof("\0__CLASS__") + EG(scope)->name->len;
@ -265,7 +265,7 @@ static zend_constant *zend_get_special_constant(const char *name, uint name_len
!memcmp(name, "__COMPILER_HALT_OFFSET__", sizeof("__COMPILER_HALT_OFFSET__")-1)) {
const char *cfilename;
zend_string *haltname;
int clen;
size_t clen;
cfilename = zend_get_executed_filename(TSRMLS_C);
clen = strlen(cfilename);
@ -281,7 +281,7 @@ static zend_constant *zend_get_special_constant(const char *name, uint name_len
}
ZEND_API zval *zend_get_constant_str(const char *name, uint name_len TSRMLS_DC)
ZEND_API zval *zend_get_constant_str(const char *name, size_t name_len TSRMLS_DC)
{
zend_constant *c;
ALLOCA_FLAG(use_heap)
@ -330,7 +330,7 @@ ZEND_API zval *zend_get_constant_ex(zend_string *cname, zend_class_entry *scope,
zend_class_entry *ce = NULL;
zend_string *class_name;
const char *name = cname->val;
uint name_len = cname->len;
size_t name_len = cname->len;
/* Skip leading \\ */
if (name[0] == '\\') {
@ -342,7 +342,7 @@ ZEND_API zval *zend_get_constant_ex(zend_string *cname, zend_class_entry *scope,
if ((colon = zend_memrchr(name, ':', name_len)) &&
colon > name && (*(colon - 1) == ':')) {
int class_name_len = colon - name - 1;
int const_name_len = name_len - class_name_len - 2;
size_t const_name_len = name_len - class_name_len - 2;
zend_string *constant_name = zend_string_init(colon + 1, const_name_len, 0);
char *lcname;
zval *ret_constant = NULL;
@ -408,10 +408,10 @@ ZEND_API zval *zend_get_constant_ex(zend_string *cname, zend_class_entry *scope,
if ((colon = zend_memrchr(name, '\\', name_len)) != NULL) {
/* compound constant name */
int prefix_len = colon - name;
int const_name_len = name_len - prefix_len - 1;
size_t const_name_len = name_len - prefix_len - 1;
const char *constant_name = colon + 1;
char *lcname;
int lcname_len;
size_t lcname_len;
ALLOCA_FLAG(use_heap)
lcname_len = prefix_len + 1 + const_name_len;

View file

@ -66,14 +66,14 @@ int zend_shutdown_constants(TSRMLS_D);
void zend_register_standard_constants(TSRMLS_D);
void clean_non_persistent_constants(TSRMLS_D);
ZEND_API zval *zend_get_constant(zend_string *name TSRMLS_DC);
ZEND_API zval *zend_get_constant_str(const char *name, uint name_len TSRMLS_DC);
ZEND_API zval *zend_get_constant_str(const char *name, size_t name_len TSRMLS_DC);
ZEND_API zval *zend_get_constant_ex(zend_string *name, zend_class_entry *scope, zend_ulong flags TSRMLS_DC);
ZEND_API void zend_register_bool_constant(const char *name, uint name_len, zend_bool bval, int flags, int module_number TSRMLS_DC);
ZEND_API void zend_register_null_constant(const char *name, uint name_len, int flags, int module_number TSRMLS_DC);
ZEND_API void zend_register_long_constant(const char *name, uint name_len, zend_long lval, int flags, int module_number TSRMLS_DC);
ZEND_API void zend_register_double_constant(const char *name, uint name_len, double dval, int flags, int module_number TSRMLS_DC);
ZEND_API void zend_register_string_constant(const char *name, uint name_len, char *strval, int flags, int module_number TSRMLS_DC);
ZEND_API void zend_register_stringl_constant(const char *name, uint name_len, char *strval, uint strlen, int flags, int module_number TSRMLS_DC);
ZEND_API void zend_register_bool_constant(const char *name, size_t name_len, zend_bool bval, int flags, int module_number TSRMLS_DC);
ZEND_API void zend_register_null_constant(const char *name, size_t name_len, int flags, int module_number TSRMLS_DC);
ZEND_API void zend_register_long_constant(const char *name, size_t name_len, zend_long lval, int flags, int module_number TSRMLS_DC);
ZEND_API void zend_register_double_constant(const char *name, size_t name_len, double dval, int flags, int module_number TSRMLS_DC);
ZEND_API void zend_register_string_constant(const char *name, size_t name_len, char *strval, int flags, int module_number TSRMLS_DC);
ZEND_API void zend_register_stringl_constant(const char *name, size_t name_len, char *strval, size_t strlen, int flags, int module_number TSRMLS_DC);
ZEND_API int zend_register_constant(zend_constant *c TSRMLS_DC);
void zend_copy_constants(HashTable *target, HashTable *sourc);
zend_constant *zend_quick_get_constant(const zval *key, zend_ulong flags TSRMLS_DC);

View file

@ -90,7 +90,7 @@ ZEND_API void zend_throw_exception_internal(zval *exception TSRMLS_DC) /* {{{ */
#ifdef HAVE_DTRACE
if (DTRACE_EXCEPTION_THROWN_ENABLED()) {
if (exception != NULL) {
DTRACE_EXCEPTION_THROWN(Z_OBJ_P(exception)->ce->val);
DTRACE_EXCEPTION_THROWN(Z_OBJ_P(exception)->ce->name->val);
} else {
DTRACE_EXCEPTION_THROWN(NULL);
}

View file

@ -547,13 +547,13 @@ static inline zval* make_real_object(zval *object_ptr TSRMLS_DC)
return object;
}
ZEND_API char * zend_verify_arg_class_kind(const zend_arg_info *cur_arg_info, zend_ulong fetch_type, char **class_name, zend_class_entry **pce TSRMLS_DC)
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_string *key;
ALLOCA_FLAG(use_heap);
STR_ALLOCA_INIT(key, cur_arg_info->class_name, cur_arg_info->class_name_len, use_heap);
*pce = zend_fetch_class(key, (fetch_type | ZEND_FETCH_CLASS_AUTO | ZEND_FETCH_CLASS_NO_AUTOLOAD) TSRMLS_CC);
*pce = zend_fetch_class(key, (ZEND_FETCH_CLASS_AUTO | ZEND_FETCH_CLASS_NO_AUTOLOAD) TSRMLS_CC);
STR_ALLOCA_FREE(key, use_heap);
*class_name = (*pce) ? (*pce)->name->val : (char*)cur_arg_info->class_name;
@ -596,7 +596,7 @@ ZEND_API void zend_verify_arg_error(int error_type, const zend_function *zf, uin
}
}
static void zend_verify_arg_type(zend_function *zf, uint32_t arg_num, zval *arg, zend_ulong fetch_type TSRMLS_DC)
static void zend_verify_arg_type(zend_function *zf, uint32_t arg_num, zval *arg TSRMLS_DC)
{
zend_arg_info *cur_arg_info;
char *need_msg;
@ -619,12 +619,12 @@ static void zend_verify_arg_type(zend_function *zf, uint32_t arg_num, zval *arg,
ZVAL_DEREF(arg);
if (Z_TYPE_P(arg) == IS_OBJECT) {
need_msg = zend_verify_arg_class_kind(cur_arg_info, fetch_type, &class_name, &ce TSRMLS_CC);
need_msg = zend_verify_arg_class_kind(cur_arg_info, &class_name, &ce TSRMLS_CC);
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) {
need_msg = zend_verify_arg_class_kind(cur_arg_info, fetch_type, &class_name, &ce 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) {
@ -645,7 +645,7 @@ static void zend_verify_arg_type(zend_function *zf, uint32_t arg_num, zval *arg,
}
}
static inline int zend_verify_missing_arg_type(zend_function *zf, uint32_t arg_num, zend_ulong fetch_type TSRMLS_DC)
static inline int zend_verify_missing_arg_type(zend_function *zf, uint32_t arg_num TSRMLS_DC)
{
zend_arg_info *cur_arg_info;
char *need_msg;
@ -666,7 +666,7 @@ static inline int zend_verify_missing_arg_type(zend_function *zf, uint32_t arg_n
if (cur_arg_info->class_name) {
char *class_name;
need_msg = zend_verify_arg_class_kind(cur_arg_info, fetch_type, &class_name, &ce 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, "none", "", NULL TSRMLS_CC);
return 0;
} else if (cur_arg_info->type_hint) {
@ -687,7 +687,7 @@ static inline int zend_verify_missing_arg_type(zend_function *zf, uint32_t arg_n
static void zend_verify_missing_arg(zend_execute_data *execute_data, uint32_t arg_num TSRMLS_DC)
{
if (EXPECTED(!(EX(func)->common.fn_flags & ZEND_ACC_HAS_TYPE_HINTS)) ||
zend_verify_missing_arg_type(EX(func), arg_num, EX(opline)->extended_value TSRMLS_CC)) {
zend_verify_missing_arg_type(EX(func), arg_num TSRMLS_CC)) {
const char *class_name = EX(func)->common.scope ? EX(func)->common.scope->name->val : "";
const char *space = EX(func)->common.scope ? "::" : "";
const char *func_name = EX(func)->common.function_name ? EX(func)->common.function_name->val : "main";
@ -1048,12 +1048,61 @@ str_index:
return retval;
}
static zend_always_inline zval *zend_fetch_dimension_address(zval *result, zval *container_ptr, zval *dim, int dim_type, int type, int is_ref, int allow_str_offset TSRMLS_DC)
static zend_never_inline zend_long zend_check_string_offset(zval *container, zval *dim, int type TSRMLS_DC)
{
zend_long offset;
if (dim == NULL) {
zend_error_noreturn(E_ERROR, "[] operator not supported for strings");
}
if (UNEXPECTED(Z_TYPE_P(dim) != IS_LONG)) {
switch(Z_TYPE_P(dim)) {
case IS_STRING:
if (IS_LONG == is_numeric_string(Z_STRVAL_P(dim), Z_STRLEN_P(dim), NULL, NULL, -1)) {
break;
}
if (type != BP_VAR_UNSET) {
zend_error(E_WARNING, "Illegal string offset '%s'", Z_STRVAL_P(dim));
}
break;
case IS_DOUBLE:
case IS_NULL:
case IS_FALSE:
case IS_TRUE:
zend_error(E_NOTICE, "String offset cast occurred");
break;
default:
zend_error(E_WARNING, "Illegal offset type");
break;
}
offset = zval_get_long(dim);
} else {
offset = Z_LVAL_P(dim);
}
return offset;
}
static zend_always_inline zend_long zend_fetch_string_offset(zval *container, zval *dim, int type TSRMLS_DC)
{
zend_long offset = zend_check_string_offset(container, dim, type TSRMLS_CC);
if (Z_REFCOUNTED_P(container)) {
if (Z_REFCOUNT_P(container) > 1) {
Z_DELREF_P(container);
zval_copy_ctor_func(container);
}
Z_ADDREF_P(container);
}
return offset;
}
static zend_always_inline void zend_fetch_dimension_address(zval *result, zval *container, zval *dim, int dim_type, int type TSRMLS_DC)
{
zval *retval;
zval *container = container_ptr;
ZVAL_DEREF(container);
if (EXPECTED(Z_TYPE_P(container) == IS_ARRAY)) {
SEPARATE_ARRAY(container);
fetch_from_array:
@ -1066,13 +1115,8 @@ fetch_from_array:
} else {
retval = zend_fetch_dimension_address_inner(Z_ARRVAL_P(container), dim, dim_type, type TSRMLS_CC);
}
if (is_ref) {
ZVAL_MAKE_REF(retval);
}
ZVAL_INDIRECT(result, retval);
} else if (EXPECTED(Z_TYPE_P(container) == IS_STRING)) {
zend_long offset;
if (type != BP_VAR_UNSET && UNEXPECTED(Z_STRLEN_P(container) == 0)) {
zval_ptr_dtor_nogc(container);
convert_to_array:
@ -1081,49 +1125,9 @@ convert_to_array:
goto fetch_from_array;
}
if (dim == NULL) {
zend_error_noreturn(E_ERROR, "[] operator not supported for strings");
}
if (UNEXPECTED(Z_TYPE_P(dim) != IS_LONG)) {
switch(Z_TYPE_P(dim)) {
case IS_STRING:
if (IS_LONG == is_numeric_string(Z_STRVAL_P(dim), Z_STRLEN_P(dim), NULL, NULL, -1)) {
break;
}
if (type != BP_VAR_UNSET) {
zend_error(E_WARNING, "Illegal string offset '%s'", Z_STRVAL_P(dim));
}
break;
case IS_DOUBLE:
case IS_NULL:
case IS_FALSE:
case IS_TRUE:
zend_error(E_NOTICE, "String offset cast occurred");
break;
default:
zend_error(E_WARNING, "Illegal offset type");
break;
}
offset = zval_get_long(dim);
} else {
offset = Z_LVAL_P(dim);
}
if (allow_str_offset) {
if (Z_REFCOUNTED_P(container)) {
if (Z_REFCOUNT_P(container) > 1) {
Z_DELREF_P(container);
zval_copy_ctor_func(container);
}
Z_ADDREF_P(container);
}
ZVAL_LONG(result, offset);
return container; /* assignment to string offset */
} else {
ZVAL_INDIRECT(result, NULL); /* wrong string offset */
}
zend_check_string_offset(container, dim, type TSRMLS_CC);
ZVAL_INDIRECT(result, NULL); /* wrong string offset */
} else if (EXPECTED(Z_TYPE_P(container) == IS_OBJECT)) {
if (!Z_OBJ_HT_P(container)->read_dimension) {
zend_error_noreturn(E_ERROR, "Cannot use object as array");
@ -1154,9 +1158,6 @@ convert_to_array:
}
}
if (result != retval) {
if (is_ref) {
ZVAL_MAKE_REF(retval);
}
ZVAL_INDIRECT(result, retval);
}
} else {
@ -1185,32 +1186,21 @@ convert_to_array:
ZVAL_INDIRECT(result, &EG(error_zval));
}
}
return NULL; /* not an assignment to string offset */
}
static zend_never_inline void zend_fetch_dimension_address_W(zval *result, zval *container_ptr, zval *dim, int dim_type TSRMLS_DC)
{
zend_fetch_dimension_address(result, container_ptr, dim, dim_type, BP_VAR_W, 0, 0 TSRMLS_CC);
}
static zend_never_inline zval *zend_fetch_dimension_address_W_str(zval *result, zval *container_ptr, zval *dim, int dim_type TSRMLS_DC)
{
return zend_fetch_dimension_address(result, container_ptr, dim, dim_type, BP_VAR_W, 0, 1 TSRMLS_CC);
}
static zend_never_inline void zend_fetch_dimension_address_W_ref(zval *result, zval *container_ptr, zval *dim, int dim_type TSRMLS_DC)
{
zend_fetch_dimension_address(result, container_ptr, dim, dim_type, BP_VAR_W, 1, 0 TSRMLS_CC);
zend_fetch_dimension_address(result, container_ptr, dim, dim_type, BP_VAR_W TSRMLS_CC);
}
static zend_never_inline void zend_fetch_dimension_address_RW(zval *result, zval *container_ptr, zval *dim, int dim_type TSRMLS_DC)
{
zend_fetch_dimension_address(result, container_ptr, dim, dim_type, BP_VAR_RW, 0, 0 TSRMLS_CC);
zend_fetch_dimension_address(result, container_ptr, dim, dim_type, BP_VAR_RW TSRMLS_CC);
}
static zend_never_inline void zend_fetch_dimension_address_UNSET(zval *result, zval *container_ptr, zval *dim, int dim_type TSRMLS_DC)
{
zend_fetch_dimension_address(result, container_ptr, dim, dim_type, BP_VAR_UNSET, 0, 0 TSRMLS_CC);
zend_fetch_dimension_address(result, container_ptr, dim, dim_type, BP_VAR_UNSET TSRMLS_CC);
}
static zend_always_inline void zend_fetch_dimension_address_read(zval *result, zval *container, zval *dim, int dim_type, int type TSRMLS_DC)
@ -1302,7 +1292,7 @@ ZEND_API void zend_fetch_dimension_by_zval(zval *result, zval *container, zval *
zend_fetch_dimension_address_read_R(result, container, dim, IS_TMP_VAR TSRMLS_CC);
}
static zend_always_inline void zend_fetch_property_address(zval *result, zval *container, uint32_t container_op_type, zval *prop_ptr, void **cache_slot, int type, int is_ref TSRMLS_DC)
static zend_always_inline void zend_fetch_property_address(zval *result, zval *container, uint32_t container_op_type, zval *prop_ptr, void **cache_slot, int type TSRMLS_DC)
{
if (container_op_type != IS_UNUSED) {
ZVAL_DEREF(container);
@ -1332,26 +1322,17 @@ static zend_always_inline void zend_fetch_property_address(zval *result, zval *c
if (Z_OBJ_HT_P(container)->read_property &&
(ptr = Z_OBJ_HT_P(container)->read_property(container, prop_ptr, type, cache_slot, result TSRMLS_CC)) != NULL) {
if (ptr != result) {
if (is_ref && ptr != &EG(uninitialized_zval)) {
ZVAL_MAKE_REF(ptr);
}
ZVAL_INDIRECT(result, ptr);
}
} else {
zend_error_noreturn(E_ERROR, "Cannot access undefined property for object with overloaded property access");
}
} else {
if (is_ref) {
ZVAL_MAKE_REF(ptr);
}
ZVAL_INDIRECT(result, ptr);
}
} else if (EXPECTED(Z_OBJ_HT_P(container)->read_property)) {
zval *ptr = Z_OBJ_HT_P(container)->read_property(container, prop_ptr, type, cache_slot, result TSRMLS_CC);
if (ptr != result) {
if (is_ref && ptr != &EG(uninitialized_zval)) {
ZVAL_MAKE_REF(ptr);
}
ZVAL_INDIRECT(result, ptr);
}
} else {

View file

@ -44,11 +44,11 @@ ZEND_API int zend_is_true(zval *op TSRMLS_DC);
ZEND_API zend_class_entry *zend_lookup_class(zend_string *name TSRMLS_DC);
ZEND_API zend_class_entry *zend_lookup_class_ex(zend_string *name, const zval *key, int use_autoload TSRMLS_DC);
ZEND_API int zend_eval_string(char *str, zval *retval_ptr, char *string_name TSRMLS_DC);
ZEND_API int zend_eval_stringl(char *str, int str_len, zval *retval_ptr, char *string_name TSRMLS_DC);
ZEND_API int zend_eval_stringl(char *str, size_t str_len, zval *retval_ptr, char *string_name TSRMLS_DC);
ZEND_API int zend_eval_string_ex(char *str, zval *retval_ptr, char *string_name, int handle_exceptions TSRMLS_DC);
ZEND_API int zend_eval_stringl_ex(char *str, int str_len, zval *retval_ptr, char *string_name, int handle_exceptions TSRMLS_DC);
ZEND_API int zend_eval_stringl_ex(char *str, size_t str_len, zval *retval_ptr, char *string_name, int handle_exceptions TSRMLS_DC);
ZEND_API char * zend_verify_arg_class_kind(const zend_arg_info *cur_arg_info, zend_ulong fetch_type, char **class_name, zend_class_entry **pce TSRMLS_DC);
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)

View file

@ -529,7 +529,7 @@ ZEND_API int zval_update_constant_ex(zval *p, zend_bool inline_change, zend_clas
char *actual = Z_STRVAL_P(p);
if ((colon = (char*)zend_memrchr(Z_STRVAL_P(p), ':', Z_STRLEN_P(p)))) {
int len;
size_t len;
zend_error(E_ERROR, "Undefined class constant '%s'", Z_STRVAL_P(p));
len = Z_STRLEN_P(p) - ((colon - Z_STRVAL_P(p)) + 1);
@ -544,7 +544,7 @@ ZEND_API int zval_update_constant_ex(zval *p, zend_bool inline_change, zend_clas
} else {
zend_string *save = Z_STR_P(p);
char *slash;
int actual_len = Z_STRLEN_P(p);
size_t actual_len = Z_STRLEN_P(p);
if ((Z_CONST_FLAGS_P(p) & IS_CONSTANT_UNQUALIFIED) && (slash = (char *)zend_memrchr(actual, '\\', actual_len))) {
actual = slash + 1;
actual_len -= (actual - Z_STRVAL_P(p));
@ -1055,7 +1055,7 @@ ZEND_API zend_class_entry *zend_lookup_class(zend_string *name TSRMLS_DC) /* {{{
}
/* }}} */
ZEND_API int zend_eval_stringl(char *str, int str_len, zval *retval_ptr, char *string_name TSRMLS_DC) /* {{{ */
ZEND_API int zend_eval_stringl(char *str, size_t str_len, zval *retval_ptr, char *string_name TSRMLS_DC) /* {{{ */
{
zval pv;
zend_op_array *new_op_array;
@ -1123,7 +1123,7 @@ ZEND_API int zend_eval_string(char *str, zval *retval_ptr, char *string_name TSR
}
/* }}} */
ZEND_API int zend_eval_stringl_ex(char *str, int str_len, zval *retval_ptr, char *string_name, int handle_exceptions TSRMLS_DC) /* {{{ */
ZEND_API int zend_eval_stringl_ex(char *str, size_t str_len, zval *retval_ptr, char *string_name, int handle_exceptions TSRMLS_DC) /* {{{ */
{
int result;

View file

@ -99,19 +99,34 @@ static const uint32_t uninitialized_bucket = {INVALID_IDX};
ZEND_API void _zend_hash_init(HashTable *ht, uint32_t nSize, dtor_func_t pDestructor, zend_bool persistent ZEND_FILE_LINE_DC)
{
uint32_t i = 3;
SET_INCONSISTENT(HT_OK);
if (nSize >= 0x80000000) {
/* Use big enough power of 2 */
#ifdef PHP_WIN32
if (nSize <= 8) {
ht->nTableSize = 8;
} else if (nSize >= 0x80000000) {
/* prevent overflow */
ht->nTableSize = 0x80000000;
} else {
while ((1U << i) < nSize) {
i++;
ht->nTableSize = 1U << __lzcnt(nSize);
if (ht->nTableSize < nSize) {
ht->nTableSize <<= 1;
}
ht->nTableSize = 1 << i;
}
#else
/* size should be between 8 and 0x80000000 */
nSize = (nSize <= 8 ? 8 : (nSize >= 0x80000000 ? 0x80000000 : nSize));
# if defined(__GNUC__)
ht->nTableSize = 0x2 << (__builtin_clz(nSize - 1) ^ 0x1f);
# else
nSize -= 1;
nSize |= (nSize >> 1);
nSize |= (nSize >> 2);
nSize |= (nSize >> 4);
nSize |= (nSize >> 8);
nSize |= (nSize >> 16);
ht->nTableSize = nSize + 1;
# endif
#endif
ht->nTableMask = 0; /* 0 means that ht->arBuckets is uninitialized */
ht->nNumUsed = 0;
@ -121,11 +136,7 @@ ZEND_API void _zend_hash_init(HashTable *ht, uint32_t nSize, dtor_func_t pDestru
ht->arHash = (uint32_t*)&uninitialized_bucket;
ht->pDestructor = pDestructor;
ht->nInternalPointer = INVALID_IDX;
if (persistent) {
ht->u.flags = HASH_FLAG_PERSISTENT | HASH_FLAG_APPLY_PROTECTION;
} else {
ht->u.flags = HASH_FLAG_APPLY_PROTECTION;
}
ht->u.flags = (persistent ? HASH_FLAG_PERSISTENT : 0) | HASH_FLAG_APPLY_PROTECTION;
}
static void zend_hash_packed_grow(HashTable *ht)
@ -1749,11 +1760,12 @@ ZEND_API int zend_hash_compare(HashTable *ht1, HashTable *ht2, compare_func_t co
return result;
}
} else { /* string indices */
result = (p1->key ? p1->key->len : 0) - (p2->key ? p2->key->len : 0);
if (result != 0) {
size_t len0 = (p1->key ? p1->key->len : 0);
size_t len1 = (p2->key ? p2->key->len : 0);
if (len0 != len1) {
HASH_UNPROTECT_RECURSION(ht1);
HASH_UNPROTECT_RECURSION(ht2);
return result;
return len0 > len1 ? 1 : -1;
}
result = memcmp(p1->key->val, p2->key->val, p1->key->len);
if (result != 0) {

View file

@ -54,7 +54,7 @@ ZEND_API void zend_html_putc(char c)
}
ZEND_API void zend_html_puts(const char *s, uint len TSRMLS_DC)
ZEND_API void zend_html_puts(const char *s, size_t len TSRMLS_DC)
{
const unsigned char *ptr = (const unsigned char*)s, *end = ptr + len;
unsigned char *filtered = NULL;

View file

@ -44,7 +44,7 @@ ZEND_API void zend_strip(TSRMLS_D);
ZEND_API int highlight_file(char *filename, zend_syntax_highlighter_ini *syntax_highlighter_ini TSRMLS_DC);
ZEND_API int highlight_string(zval *str, zend_syntax_highlighter_ini *syntax_highlighter_ini, char *str_name TSRMLS_DC);
ZEND_API void zend_html_putc(char c);
ZEND_API void zend_html_puts(const char *s, uint len TSRMLS_DC);
ZEND_API void zend_html_puts(const char *s, size_t len TSRMLS_DC);
END_EXTERN_C()
extern zend_syntax_highlighter_ini syntax_highlighter_ini;

View file

@ -268,12 +268,7 @@ static zend_always_inline int zend_verify_property_access(zend_property_info *pr
case ZEND_ACC_PROTECTED:
return zend_check_protected(property_info->ce, EG(scope));
case ZEND_ACC_PRIVATE:
if ((ce==EG(scope) || property_info->ce == EG(scope)) && EG(scope)) {
return 1;
} else {
return 0;
}
break;
return (ce == EG(scope) || property_info->ce == EG(scope));
}
return 0;
}
@ -295,9 +290,9 @@ static zend_always_inline zend_bool is_derived_class(zend_class_entry *child_cla
static zend_always_inline zend_property_info *zend_get_property_info_quick(zend_class_entry *ce, zend_string *member, int silent, void **cache_slot TSRMLS_DC) /* {{{ */
{
zend_property_info *property_info;
zend_property_info *scope_property_info;
zend_bool denied_access = 0;
zval *zv;
zend_property_info *property_info = NULL;
uint32_t flags;
if (cache_slot && EXPECTED(ce == CACHED_PTR_EX(cache_slot))) {
return CACHED_PTR_EX(cache_slot + 1);
@ -313,60 +308,61 @@ static zend_always_inline zend_property_info *zend_get_property_info_quick(zend_
}
return ZEND_WRONG_PROPERTY_INFO;
}
property_info = zend_hash_find_ptr(&ce->properties_info, member);
if (property_info != NULL) {
if (UNEXPECTED((property_info->flags & ZEND_ACC_SHADOW) != 0)) {
if (UNEXPECTED(zend_hash_num_elements(&ce->properties_info) == 0)) {
goto exit_dynamic;
}
zv = zend_hash_find(&ce->properties_info, member);
if (EXPECTED(zv != NULL)) {
property_info = (zend_property_info*)Z_PTR_P(zv);
flags = property_info->flags;
if (UNEXPECTED((flags & ZEND_ACC_SHADOW) != 0)) {
/* if it's a shadow - go to access it's private */
property_info = NULL;
} else {
if (EXPECTED(zend_verify_property_access(property_info, ce TSRMLS_CC) != 0)) {
if (EXPECTED((property_info->flags & ZEND_ACC_CHANGED) != 0)
&& EXPECTED(!(property_info->flags & ZEND_ACC_PRIVATE))) {
/* We still need to make sure that we're not in a context
* where the right property is a different 'statically linked' private
* continue checking below...
*/
} else {
if (UNEXPECTED((property_info->flags & ZEND_ACC_STATIC) != 0) && !silent) {
if (UNEXPECTED(!(flags & ZEND_ACC_CHANGED))
|| UNEXPECTED((flags & ZEND_ACC_PRIVATE))) {
if (UNEXPECTED((flags & ZEND_ACC_STATIC) != 0) && !silent) {
zend_error(E_STRICT, "Accessing static property %s::$%s as non static", ce->name->val, member->val);
}
if (cache_slot) {
CACHE_POLYMORPHIC_PTR_EX(cache_slot, ce, property_info);
}
return property_info;
goto exit;
}
} else {
/* Try to look in the scope instead */
denied_access = 1;
property_info = ZEND_WRONG_PROPERTY_INFO;
}
}
}
if (EG(scope) != ce
&& EG(scope)
&& is_derived_class(ce, EG(scope))
&& (scope_property_info = zend_hash_find_ptr(&EG(scope)->properties_info, member)) != NULL
&& scope_property_info->flags & ZEND_ACC_PRIVATE) {
if (cache_slot) {
CACHE_POLYMORPHIC_PTR_EX(cache_slot, ce, scope_property_info);
}
return scope_property_info;
} else if (property_info) {
if (UNEXPECTED(denied_access != 0)) {
/* Information was available, but we were denied access. Error out. */
if (!silent) {
zend_error_noreturn(E_ERROR, "Cannot access %s property %s::$%s", zend_visibility_string(property_info->flags), ce->name->val, member->val);
}
return ZEND_WRONG_PROPERTY_INFO;
} else {
/* fall through, return property_info... */
if (cache_slot) {
CACHE_POLYMORPHIC_PTR_EX(cache_slot, ce, property_info);
}
}
} else {
&& (zv = zend_hash_find(&EG(scope)->properties_info, member)) != NULL
&& ((zend_property_info*)Z_PTR_P(zv))->flags & ZEND_ACC_PRIVATE) {
property_info = (zend_property_info*)Z_PTR_P(zv);
goto exit;
} else if (UNEXPECTED(property_info == NULL)) {
exit_dynamic:
if (cache_slot) {
CACHE_POLYMORPHIC_PTR_EX(cache_slot, ce, NULL);
}
return NULL;
} else if (UNEXPECTED(property_info == ZEND_WRONG_PROPERTY_INFO)) {
/* Information was available, but we were denied access. Error out. */
if (!silent) {
zend_error_noreturn(E_ERROR, "Cannot access %s property %s::$%s", zend_visibility_string(flags), ce->name->val, member->val);
}
if (cache_slot) {
CACHE_POLYMORPHIC_PTR_EX(cache_slot, ce, ZEND_WRONG_PROPERTY_INFO);
}
return ZEND_WRONG_PROPERTY_INFO;
}
exit:
if (cache_slot) {
CACHE_POLYMORPHIC_PTR_EX(cache_slot, ce, property_info);
}
return property_info;
}
@ -462,12 +458,12 @@ zval *zend_std_read_property(zval *object, zval *member, int type, void **cache_
EXPECTED((property_info->flags & ZEND_ACC_STATIC) == 0)) {
retval = &zobj->properties_table[property_info->offset];
if (Z_TYPE_P(retval) != IS_UNDEF) {
if (EXPECTED(Z_TYPE_P(retval) != IS_UNDEF)) {
goto exit;
}
} else if (UNEXPECTED(zobj->properties != NULL)) {
} else if (EXPECTED(zobj->properties != NULL)) {
retval = zend_hash_find(zobj->properties, Z_STR_P(member));
if (retval) goto exit;
if (EXPECTED(retval)) goto exit;
}
}
@ -831,7 +827,7 @@ static void zend_std_unset_property(zval *object, zval *member, void **cache_slo
ZVAL_UNDEF(&zobj->properties_table[property_info->offset]);
goto exit;
}
} else if (zobj->properties &&
} else if (EXPECTED(zobj->properties != NULL) &&
EXPECTED(zend_hash_del(zobj->properties, Z_STR_P(member)) != FAILURE)) {
goto exit;
}
@ -1427,7 +1423,7 @@ static int zend_std_has_property(zval *object, zval *member, int has_set_exists,
if (Z_TYPE_P(value) != IS_UNDEF) {
goto found;
}
} else if (UNEXPECTED(zobj->properties != NULL) &&
} else if (EXPECTED(zobj->properties != NULL) &&
(value = zend_hash_find(zobj->properties, Z_STR_P(member))) != NULL) {
found:
switch (has_set_exists) {

View file

@ -144,7 +144,8 @@ ZEND_API void zend_objects_clone_members(zend_object *new_object, zend_object *o
if (old_object->ce->default_properties_count) {
for (i = 0; i < old_object->ce->default_properties_count; i++) {
zval_ptr_dtor(&new_object->properties_table[i]);
ZVAL_COPY(&new_object->properties_table[i], &old_object->properties_table[i]);
ZVAL_COPY_VALUE(&new_object->properties_table[i], &old_object->properties_table[i]);
zval_add_ref(&new_object->properties_table[i]);
}
}
if (old_object->properties) {

View file

@ -924,7 +924,7 @@ ZEND_API int add_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) /* {{{ *
} else if (Z_ISREF_P(op2)) {
op2 = Z_REFVAL_P(op2);
} else if (!converted) {
ZEND_TRY_BINARY_OBJECT_OPERATION(ZEND_ADD);
ZEND_TRY_BINARY_OBJECT_OPERATION(ZEND_ADD, add_function);
zendi_convert_scalar_to_number(op1, op1_copy, result);
zendi_convert_scalar_to_number(op2, op2_copy, result);
@ -977,7 +977,7 @@ ZEND_API int sub_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) /* {{{ *
} else if (Z_ISREF_P(op2)) {
op2 = Z_REFVAL_P(op2);
} else if (!converted) {
ZEND_TRY_BINARY_OBJECT_OPERATION(ZEND_SUB);
ZEND_TRY_BINARY_OBJECT_OPERATION(ZEND_SUB, sub_function);
zendi_convert_scalar_to_number(op1, op1_copy, result);
zendi_convert_scalar_to_number(op2, op2_copy, result);
@ -1024,7 +1024,7 @@ ZEND_API int mul_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) /* {{{ *
} else if (Z_ISREF_P(op2)) {
op2 = Z_REFVAL_P(op2);
} else if (!converted) {
ZEND_TRY_BINARY_OBJECT_OPERATION(ZEND_MUL);
ZEND_TRY_BINARY_OBJECT_OPERATION(ZEND_MUL, mul_function);
zendi_convert_scalar_to_number(op1, op1_copy, result);
zendi_convert_scalar_to_number(op2, op2_copy, result);
@ -1102,7 +1102,7 @@ ZEND_API int pow_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) /* {{{ *
} else if (Z_ISREF_P(op2)) {
op2 = Z_REFVAL_P(op2);
} else if (!converted) {
ZEND_TRY_BINARY_OBJECT_OPERATION(ZEND_POW);
ZEND_TRY_BINARY_OBJECT_OPERATION(ZEND_POW, pow_function);
if (Z_TYPE_P(op1) == IS_ARRAY) {
ZVAL_LONG(result, 0);
@ -1183,7 +1183,7 @@ ZEND_API int div_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) /* {{{ *
} else if (Z_ISREF_P(op2)) {
op2 = Z_REFVAL_P(op2);
} else if (!converted) {
ZEND_TRY_BINARY_OBJECT_OPERATION(ZEND_DIV);
ZEND_TRY_BINARY_OBJECT_OPERATION(ZEND_DIV, div_function);
zendi_convert_scalar_to_number(op1, op1_copy, result);
zendi_convert_scalar_to_number(op2, op2_copy, result);
@ -1202,14 +1202,14 @@ ZEND_API int mod_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) /* {{{ *
zval op1_copy, op2_copy;
zend_long op1_lval;
if (Z_TYPE_P(op1) != IS_LONG || Z_TYPE_P(op2) != IS_LONG) {
ZEND_TRY_BINARY_OBJECT_OPERATION(ZEND_MOD);
if (UNEXPECTED(Z_TYPE_P(op1) != IS_LONG)) {
ZEND_TRY_BINARY_OP1_OBJECT_OPERATION(ZEND_MOD, mod_function);
zendi_convert_to_long(op1, op1_copy, result);
op1_lval = Z_LVAL_P(op1);
}
op1_lval = Z_LVAL_P(op1);
if (UNEXPECTED(Z_TYPE_P(op2) != IS_LONG)) {
ZEND_TRY_BINARY_OP2_OBJECT_OPERATION(ZEND_MOD);
zendi_convert_to_long(op2, op2_copy, result);
} else {
op1_lval = Z_LVAL_P(op1);
}
if (Z_LVAL_P(op2) == 0) {
@ -1234,15 +1234,14 @@ ZEND_API int boolean_xor_function(zval *result, zval *op1, zval *op2 TSRMLS_DC)
zval op1_copy, op2_copy;
zend_long op1_lval;
if ((Z_TYPE_P(op1) != IS_FALSE && Z_TYPE_P(op1) != IS_TRUE) ||
(Z_TYPE_P(op2) != IS_FALSE && Z_TYPE_P(op2) != IS_TRUE)) {
ZEND_TRY_BINARY_OBJECT_OPERATION(ZEND_BOOL_XOR);
if (UNEXPECTED(Z_TYPE_P(op1) != IS_FALSE && Z_TYPE_P(op1) != IS_TRUE)) {
ZEND_TRY_BINARY_OP1_OBJECT_OPERATION(ZEND_BOOL_XOR, boolean_xor_function);
zendi_convert_to_boolean(op1, op1_copy, result);
op1_lval = Z_TYPE_P(op1) == IS_TRUE;
}
op1_lval = Z_TYPE_P(op1) == IS_TRUE;
if (UNEXPECTED(Z_TYPE_P(op2) != IS_FALSE && Z_TYPE_P(op2) != IS_TRUE)) {
ZEND_TRY_BINARY_OP2_OBJECT_OPERATION(ZEND_BOOL_XOR);
zendi_convert_to_boolean(op2, op2_copy, result);
} else {
op1_lval = Z_TYPE_P(op1) == IS_TRUE;
}
ZVAL_BOOL(result, op1_lval ^ (Z_TYPE_P(op2) == IS_TRUE));
@ -1281,11 +1280,10 @@ ZEND_API int bitwise_not_function(zval *result, zval *op1 TSRMLS_DC) /* {{{ */
return SUCCESS;
case IS_STRING: {
size_t i;
zval op1_copy = *op1;
ZVAL_NEW_STR(result, zend_string_alloc(Z_STRLEN(op1_copy), 0));
for (i = 0; i < Z_STRLEN(op1_copy); i++) {
Z_STRVAL_P(result)[i] = ~Z_STRVAL(op1_copy)[i];
ZVAL_NEW_STR(result, zend_string_alloc(Z_STRLEN_P(op1), 0));
for (i = 0; i < Z_STRLEN_P(op1); i++) {
Z_STRVAL_P(result)[i] = ~Z_STRVAL_P(op1)[i];
}
Z_STRVAL_P(result)[i] = 0;
return SUCCESS;
@ -1329,14 +1327,14 @@ ZEND_API int bitwise_or_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) /
return SUCCESS;
}
if (Z_TYPE_P(op1) != IS_LONG || Z_TYPE_P(op2) != IS_LONG) {
ZEND_TRY_BINARY_OBJECT_OPERATION(ZEND_BW_OR);
if (UNEXPECTED(Z_TYPE_P(op1) != IS_LONG)) {
ZEND_TRY_BINARY_OP1_OBJECT_OPERATION(ZEND_BW_OR, bitwise_or_function);
zendi_convert_to_long(op1, op1_copy, result);
op1_lval = Z_LVAL_P(op1);
}
op1_lval = Z_LVAL_P(op1);
if (UNEXPECTED(Z_TYPE_P(op2) != IS_LONG)) {
ZEND_TRY_BINARY_OP2_OBJECT_OPERATION(ZEND_BW_OR);
zendi_convert_to_long(op2, op2_copy, result);
} else {
op1_lval = Z_LVAL_P(op1);
}
ZVAL_LONG(result, op1_lval | Z_LVAL_P(op2));
@ -1374,14 +1372,14 @@ ZEND_API int bitwise_and_function(zval *result, zval *op1, zval *op2 TSRMLS_DC)
return SUCCESS;
}
if (Z_TYPE_P(op1) != IS_LONG || Z_TYPE_P(op2) != IS_LONG) {
ZEND_TRY_BINARY_OBJECT_OPERATION(ZEND_BW_AND);
if (UNEXPECTED(Z_TYPE_P(op1) != IS_LONG)) {
ZEND_TRY_BINARY_OP1_OBJECT_OPERATION(ZEND_BW_AND, bitwise_and_function);
zendi_convert_to_long(op1, op1_copy, result);
op1_lval = Z_LVAL_P(op1);
}
op1_lval = Z_LVAL_P(op1);
if (UNEXPECTED(Z_TYPE_P(op2) != IS_LONG)) {
ZEND_TRY_BINARY_OP2_OBJECT_OPERATION(ZEND_BW_AND);
zendi_convert_to_long(op2, op2_copy, result);
} else {
op1_lval = Z_LVAL_P(op1);
}
ZVAL_LONG(result, op1_lval & Z_LVAL_P(op2));
@ -1419,14 +1417,14 @@ ZEND_API int bitwise_xor_function(zval *result, zval *op1, zval *op2 TSRMLS_DC)
return SUCCESS;
}
if (Z_TYPE_P(op1) != IS_LONG || Z_TYPE_P(op2) != IS_LONG) {
ZEND_TRY_BINARY_OBJECT_OPERATION(ZEND_BW_XOR);
if (UNEXPECTED(Z_TYPE_P(op1) != IS_LONG)) {
ZEND_TRY_BINARY_OP1_OBJECT_OPERATION(ZEND_BW_XOR, bitwise_xor_function);
zendi_convert_to_long(op1, op1_copy, result);
op1_lval = Z_LVAL_P(op1);
}
op1_lval = Z_LVAL_P(op1);
if (UNEXPECTED(Z_TYPE_P(op2) != IS_LONG)) {
ZEND_TRY_BINARY_OP2_OBJECT_OPERATION(ZEND_BW_XOR);
zendi_convert_to_long(op2, op2_copy, result);
} else {
op1_lval = Z_LVAL_P(op1);
}
ZVAL_LONG(result, op1_lval ^ Z_LVAL_P(op2));
@ -1439,14 +1437,14 @@ ZEND_API int shift_left_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) /
zval op1_copy, op2_copy;
zend_long op1_lval;
if (Z_TYPE_P(op1) != IS_LONG || Z_TYPE_P(op2) != IS_LONG) {
ZEND_TRY_BINARY_OBJECT_OPERATION(ZEND_SL);
if (UNEXPECTED(Z_TYPE_P(op1) != IS_LONG)) {
ZEND_TRY_BINARY_OP1_OBJECT_OPERATION(ZEND_SL, shift_left_function);
zendi_convert_to_long(op1, op1_copy, result);
op1_lval = Z_LVAL_P(op1);
}
op1_lval = Z_LVAL_P(op1);
if (UNEXPECTED(Z_TYPE_P(op2) != IS_LONG)) {
ZEND_TRY_BINARY_OP2_OBJECT_OPERATION(ZEND_SL);
zendi_convert_to_long(op2, op2_copy, result);
} else {
op1_lval = Z_LVAL_P(op1);
}
/* prevent wrapping quirkiness on some processors where << 64 + x == << x */
@ -1471,14 +1469,14 @@ ZEND_API int shift_right_function(zval *result, zval *op1, zval *op2 TSRMLS_DC)
zval op1_copy, op2_copy;
zend_long op1_lval;
if (Z_TYPE_P(op1) != IS_LONG || Z_TYPE_P(op2) != IS_LONG) {
ZEND_TRY_BINARY_OBJECT_OPERATION(ZEND_SR);
if (UNEXPECTED(Z_TYPE_P(op1) != IS_LONG)) {
ZEND_TRY_BINARY_OP1_OBJECT_OPERATION(ZEND_SR, shift_right_function);
zendi_convert_to_long(op1, op1_copy, result);
op1_lval = Z_LVAL_P(op1);
}
op1_lval = Z_LVAL_P(op1);
if (UNEXPECTED(Z_TYPE_P(op2) != IS_LONG)) {
ZEND_TRY_BINARY_OP2_OBJECT_OPERATION(ZEND_SR);
zendi_convert_to_long(op2, op2_copy, result);
} else {
op1_lval = Z_LVAL_P(op1);
}
/* prevent wrapping quirkiness on some processors where >> 64 + x == >> x */
@ -1530,29 +1528,28 @@ ZEND_API int concat_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) /* {{
zval op1_copy, op2_copy;
int use_copy1 = 0, use_copy2 = 0;
if (UNEXPECTED(Z_TYPE_P(op1) != IS_STRING) ||
UNEXPECTED(Z_TYPE_P(op2) != IS_STRING)) {
ZEND_TRY_BINARY_OBJECT_OPERATION(ZEND_CONCAT);
if (Z_TYPE_P(op1) != IS_STRING) {
use_copy1 = zend_make_printable_zval(op1, &op1_copy TSRMLS_CC);
}
if (Z_TYPE_P(op2) != IS_STRING) {
use_copy2 = zend_make_printable_zval(op2, &op2_copy TSRMLS_CC);
if (UNEXPECTED(Z_TYPE_P(op1) != IS_STRING)) {
ZEND_TRY_BINARY_OBJECT_OPERATION(ZEND_CONCAT, concat_function);
use_copy1 = zend_make_printable_zval(op1, &op1_copy TSRMLS_CC);
if (use_copy1) {
/* We have created a converted copy of op1. Therefore, op1 won't become the result so
* we have to free it.
*/
if (result == op1) {
zval_dtor(op1);
if (UNEXPECTED(op1 == op2)) {
op2 = &op1_copy;
}
}
op1 = &op1_copy;
}
}
if (use_copy1) {
/* We have created a converted copy of op1. Therefore, op1 won't become the result so
* we have to free it.
*/
if (result == op1) {
zval_dtor(op1);
if (UNEXPECTED(Z_TYPE_P(op2) != IS_STRING)) {
ZEND_TRY_BINARY_OP2_OBJECT_OPERATION(ZEND_CONCAT);
use_copy2 = zend_make_printable_zval(op2, &op2_copy TSRMLS_CC);
if (use_copy2) {
op2 = &op2_copy;
}
op1 = &op1_copy;
}
if (use_copy2) {
op2 = &op2_copy;
}
{

View file

@ -887,22 +887,43 @@ static zend_always_inline void fast_is_not_identical_function(zval *result, zval
ZVAL_BOOL(result, Z_TYPE_P(result) != IS_TRUE);
}
#define ZEND_TRY_BINARY_OBJECT_OPERATION(opcode) \
if (Z_TYPE_P(op1) == IS_OBJECT && Z_OBJ_HANDLER_P(op1, do_operation)) { \
if (SUCCESS == Z_OBJ_HANDLER_P(op1, do_operation)(opcode, result, op1, op2 TSRMLS_CC)) { \
return SUCCESS; \
} \
} else if (Z_TYPE_P(op2) == IS_OBJECT && Z_OBJ_HANDLER_P(op2, do_operation)) { \
if (SUCCESS == Z_OBJ_HANDLER_P(op2, do_operation)(opcode, result, op1, op2 TSRMLS_CC)) { \
return SUCCESS; \
} \
#define ZEND_TRY_BINARY_OP1_OBJECT_OPERATION(opcode, binary_op) \
if (UNEXPECTED(Z_TYPE_P(op1) == IS_OBJECT) \
&& op1 == result \
&& UNEXPECTED(Z_OBJ_HANDLER_P(op1, get)) \
&& EXPECTED(Z_OBJ_HANDLER_P(op1, set))) { \
int ret; \
zval rv; \
zval *objval = Z_OBJ_HANDLER_P(op1, get)(op1, &rv TSRMLS_CC); \
Z_ADDREF_P(objval); \
ret = binary_op(objval, objval, op2 TSRMLS_CC); \
Z_OBJ_HANDLER_P(op1, set)(op1, objval TSRMLS_CC); \
zval_ptr_dtor(objval); \
return ret; \
} else if (UNEXPECTED(Z_TYPE_P(op1) == IS_OBJECT) \
&& UNEXPECTED(Z_OBJ_HANDLER_P(op1, do_operation))) { \
if (EXPECTED(SUCCESS == Z_OBJ_HANDLER_P(op1, do_operation)(opcode, result, op1, op2 TSRMLS_CC))) { \
return SUCCESS; \
} \
}
#define ZEND_TRY_UNARY_OBJECT_OPERATION(opcode) \
if (Z_TYPE_P(op1) == IS_OBJECT && Z_OBJ_HANDLER_P(op1, do_operation) \
&& SUCCESS == Z_OBJ_HANDLER_P(op1, do_operation)(opcode, result, op1, NULL TSRMLS_CC) \
) { \
return SUCCESS; \
#define ZEND_TRY_BINARY_OP2_OBJECT_OPERATION(opcode) \
if (UNEXPECTED(Z_TYPE_P(op2) == IS_OBJECT) \
&& UNEXPECTED(Z_OBJ_HANDLER_P(op2, do_operation)) \
&& EXPECTED(SUCCESS == Z_OBJ_HANDLER_P(op2, do_operation)(opcode, result, op1, op2 TSRMLS_CC))) { \
return SUCCESS; \
}
#define ZEND_TRY_BINARY_OBJECT_OPERATION(opcode, binary_op) \
ZEND_TRY_BINARY_OP1_OBJECT_OPERATION(opcode, binary_op) \
else \
ZEND_TRY_BINARY_OP2_OBJECT_OPERATION(opcode)
#define ZEND_TRY_UNARY_OBJECT_OPERATION(opcode) \
if (UNEXPECTED(Z_TYPE_P(op1) == IS_OBJECT) \
&& UNEXPECTED(Z_OBJ_HANDLER_P(op1, do_operation)) \
&& EXPECTED(SUCCESS == Z_OBJ_HANDLER_P(op1, do_operation)(opcode, result, op1, NULL TSRMLS_CC))) { \
return SUCCESS; \
}
/* buf points to the END of the buffer */

View file

@ -221,7 +221,7 @@ ZEND_API void zval_add_ref_unref(zval *p)
{
if (Z_REFCOUNTED_P(p)) {
if (Z_ISREF_P(p)) {
ZVAL_DUP(p, Z_REFVAL_P(p));
ZVAL_COPY(p, Z_REFVAL_P(p));
} else {
Z_ADDREF_P(p);
}
@ -266,7 +266,7 @@ ZEND_API void _zval_copy_ctor_func(zval *zvalue ZEND_FILE_LINE_DC)
}
ZEND_API int zend_print_variable(zval *var TSRMLS_DC)
ZEND_API size_t zend_print_variable(zval *var TSRMLS_DC)
{
return zend_print_zval(var, 0 TSRMLS_CC);
}

View file

@ -93,7 +93,7 @@ static zend_always_inline void _zval_opt_copy_ctor_no_imm(zval *zvalue ZEND_FILE
ZEND_API int zval_copy_static_var(zval *p TSRMLS_DC, int num_args, va_list args, zend_hash_key *key);
ZEND_API int zend_print_variable(zval *var TSRMLS_DC);
ZEND_API size_t zend_print_variable(zval *var TSRMLS_DC);
ZEND_API void _zval_ptr_dtor(zval *zval_ptr ZEND_FILE_LINE_DC);
ZEND_API void _zval_internal_dtor_for_ptr(zval *zvalue ZEND_FILE_LINE_DC);
ZEND_API void _zval_internal_dtor(zval *zvalue ZEND_FILE_LINE_DC);

View file

@ -380,7 +380,7 @@ CWD_API int php_sys_stat_ex(const char *path, zend_stat_t *buf, int lstat) /* {{
}
if ((data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == 0) {
int len = strlen(path);
size_t len = strlen(path);
if (path[len-4] == '.') {
if (_memicmp(path+len-3, "exe", 3) == 0 ||
@ -467,7 +467,7 @@ CWD_API void virtual_cwd_startup(void) /* {{{ */
cwd[0] = '\0';
}
main_cwd_state.cwd_length = strlen(cwd);
main_cwd_state.cwd_length = (int)strlen(cwd);
#ifdef TSRM_WIN32
if (main_cwd_state.cwd_length >= 2 && cwd[1] == ':') {
cwd[0] = toupper(cwd[0]);
@ -1146,7 +1146,7 @@ static int tsrm_realpath_r(char *path, int start, int len, int *ll, time_t *t, i
return -1;
}
if (save) {
i = strlen(data.cFileName);
i = (int)strlen(data.cFileName);
memcpy(path+j, data.cFileName, i+1);
j += i;
} else {
@ -1180,7 +1180,7 @@ static int tsrm_realpath_r(char *path, int start, int len, int *ll, time_t *t, i
/* returns 0 for ok, 1 for error */
CWD_API int virtual_file_ex(cwd_state *state, const char *path, verify_path_func verify_path, int use_realpath TSRMLS_DC) /* {{{ */
{
int path_length = strlen(path);
int path_length = (int)strlen(path);
char resolved_path[MAXPATHLEN];
int start = 1;
int ll = 0;
@ -1394,7 +1394,7 @@ CWD_API int virtual_chdir(const char *path TSRMLS_DC) /* {{{ */
CWD_API int virtual_chdir_file(const char *path, int (*p_chdir)(const char *path TSRMLS_DC) TSRMLS_DC) /* {{{ */
{
int length = strlen(path);
size_t length = strlen(path);
char *temp;
int retval;
ALLOCA_FLAG(use_heap)
@ -1972,7 +1972,7 @@ CWD_API char *tsrm_realpath(const char *path, char *real_path TSRMLS_DC) /* {{{
} else if (!IS_ABSOLUTE_PATH(path, strlen(path)) &&
VCWD_GETCWD(cwd, MAXPATHLEN)) {
new_state.cwd = estrdup(cwd);
new_state.cwd_length = strlen(cwd);
new_state.cwd_length = (int)strlen(cwd);
} else {
new_state.cwd = (char*)emalloc(1);
if (new_state.cwd == NULL) {

View file

@ -333,7 +333,7 @@ ZEND_VM_HELPER_EX(zend_binary_assign_op_obj_helper, VAR|UNUSED|CV, CONST|TMP|VAR
zval *object = GET_OP1_OBJ_ZVAL_PTR_PTR(BP_VAR_RW);
zval *property = GET_OP2_ZVAL_PTR(BP_VAR_R);
zval *value;
int have_get_ptr = 0;
zval *zptr;
if (OP1_TYPE == IS_VAR && UNEXPECTED(object == NULL)) {
zend_error_noreturn(E_ERROR, "Cannot use string offset as an object");
@ -356,21 +356,17 @@ ZEND_VM_HELPER_EX(zend_binary_assign_op_obj_helper, VAR|UNUSED|CV, CONST|TMP|VAR
} else {
/* here we are sure we are dealing with an object */
if (opline->extended_value == ZEND_ASSIGN_OBJ
&& Z_OBJ_HT_P(object)->get_property_ptr_ptr) {
zval *zptr = Z_OBJ_HT_P(object)->get_property_ptr_ptr(object, property, BP_VAR_RW, ((OP2_TYPE == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL) TSRMLS_CC);
if (zptr != NULL) { /* NULL means no success in getting PTR */
ZVAL_DEREF(zptr);
SEPARATE_ZVAL_NOREF(zptr);
&& EXPECTED(Z_OBJ_HT_P(object)->get_property_ptr_ptr)
&& EXPECTED((zptr = Z_OBJ_HT_P(object)->get_property_ptr_ptr(object, property, BP_VAR_RW, ((OP2_TYPE == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL) TSRMLS_CC)) != NULL)) {
have_get_ptr = 1;
binary_op(zptr, zptr, value TSRMLS_CC);
if (RETURN_VALUE_USED(opline)) {
ZVAL_COPY(EX_VAR(opline->result.var), zptr);
}
ZVAL_DEREF(zptr);
SEPARATE_ZVAL_NOREF(zptr);
binary_op(zptr, zptr, value TSRMLS_CC);
if (RETURN_VALUE_USED(opline)) {
ZVAL_COPY(EX_VAR(opline->result.var), zptr);
}
}
if (!have_get_ptr) {
} else {
zval *z = NULL;
zval rv;
@ -427,15 +423,19 @@ ZEND_VM_HELPER_EX(zend_binary_assign_op_obj_helper, VAR|UNUSED|CV, CONST|TMP|VAR
ZEND_VM_HELPER_EX(zend_binary_assign_op_dim_helper, VAR|UNUSED|CV, CONST|TMP|VAR|UNUSED|CV, int (*binary_op)(zval *result, zval *op1, zval *op2 TSRMLS_DC))
{
USE_OPLINE
zend_free_op free_op1, free_op2, free_op_data2, free_op_data1;
zval *var_ptr;
zend_free_op free_op1, free_op2, free_op_data1;
zval *var_ptr, rv;
zval *value, *container;
SAVE_OPLINE();
container = GET_OP1_OBJ_ZVAL_PTR_PTR(BP_VAR_RW);
if (OP1_TYPE == IS_VAR && UNEXPECTED(container == NULL)) {
zend_error_noreturn(E_ERROR, "Cannot use string offset as an array");
} else if (OP1_TYPE == IS_UNUSED || UNEXPECTED(Z_TYPE_P(container) == IS_OBJECT)) {
}
if (OP1_TYPE != IS_UNUSED) {
ZVAL_DEREF(container);
}
if (OP1_TYPE == IS_UNUSED || UNEXPECTED(Z_TYPE_P(container) == IS_OBJECT)) {
if (OP1_TYPE == IS_VAR && !OP1_FREE) {
Z_ADDREF_P(container); /* undo the effect of get_obj_zval_ptr_ptr() */
}
@ -443,9 +443,10 @@ ZEND_VM_HELPER_EX(zend_binary_assign_op_dim_helper, VAR|UNUSED|CV, CONST|TMP|VAR
} else {
zval *dim = GET_OP2_ZVAL_PTR_DEREF(BP_VAR_R);
zend_fetch_dimension_address_RW(EX_VAR((opline+1)->op2.var), container, dim, OP2_TYPE TSRMLS_CC);
zend_fetch_dimension_address_RW(&rv, container, dim, OP2_TYPE TSRMLS_CC);
value = get_zval_ptr_deref((opline+1)->op1_type, &(opline+1)->op1, execute_data, &free_op_data1, BP_VAR_R);
var_ptr = _get_zval_ptr_ptr_var((opline+1)->op2.var, execute_data, &free_op_data2 TSRMLS_CC);
ZEND_ASSERT(Z_TYPE(rv) == IS_INDIRECT);
var_ptr = Z_INDIRECT(rv);
}
if (UNEXPECTED(var_ptr == NULL)) {
@ -456,33 +457,19 @@ ZEND_VM_HELPER_EX(zend_binary_assign_op_dim_helper, VAR|UNUSED|CV, CONST|TMP|VAR
if (UNEXPECTED(RETURN_VALUE_USED(opline))) {
ZVAL_NULL(EX_VAR(opline->result.var));
}
ZEND_VM_C_GOTO(assign_op_dim_exit);
}
ZVAL_DEREF(var_ptr);
SEPARATE_ZVAL_NOREF(var_ptr);
if (UNEXPECTED(Z_TYPE_P(var_ptr) == IS_OBJECT) &&
UNEXPECTED(Z_OBJ_HANDLER_P(var_ptr, get) && Z_OBJ_HANDLER_P(var_ptr, set))) {
/* proxy object */
zval rv;
zval *objval = Z_OBJ_HANDLER_P(var_ptr, get)(var_ptr, &rv TSRMLS_CC);
Z_ADDREF_P(objval);
binary_op(objval, objval, value TSRMLS_CC);
Z_OBJ_HANDLER_P(var_ptr, set)(var_ptr, objval TSRMLS_CC);
zval_ptr_dtor(objval);
} else {
ZVAL_DEREF(var_ptr);
SEPARATE_ZVAL_NOREF(var_ptr);
binary_op(var_ptr, var_ptr, value TSRMLS_CC);
if (UNEXPECTED(RETURN_VALUE_USED(opline))) {
ZVAL_COPY(EX_VAR(opline->result.var), var_ptr);
}
}
if (UNEXPECTED(RETURN_VALUE_USED(opline))) {
ZVAL_COPY(EX_VAR(opline->result.var), var_ptr);
}
ZEND_VM_C_LABEL(assign_op_dim_exit):
FREE_OP2();
FREE_OP(free_op_data1);
FREE_OP_VAR_PTR(free_op_data2);
FREE_OP1_VAR_PTR();
CHECK_EXCEPTION();
ZEND_VM_INC_OPCODE();
@ -508,30 +495,17 @@ ZEND_VM_HELPER_EX(zend_binary_assign_op_helper, VAR|UNUSED|CV, CONST|TMP|VAR|UNU
if (UNEXPECTED(RETURN_VALUE_USED(opline))) {
ZVAL_NULL(EX_VAR(opline->result.var));
}
ZEND_VM_C_GOTO(assign_op_exit);
}
ZVAL_DEREF(var_ptr);
SEPARATE_ZVAL_NOREF(var_ptr);
if (UNEXPECTED(Z_TYPE_P(var_ptr) == IS_OBJECT) &&
UNEXPECTED(Z_OBJ_HANDLER_P(var_ptr, get) && Z_OBJ_HANDLER_P(var_ptr, set))) {
/* proxy object */
zval rv;
zval *objval = Z_OBJ_HANDLER_P(var_ptr, get)(var_ptr, &rv TSRMLS_CC);
Z_ADDREF_P(objval);
binary_op(objval, objval, value TSRMLS_CC);
Z_OBJ_HANDLER_P(var_ptr, set)(var_ptr, objval TSRMLS_CC);
zval_ptr_dtor(objval);
} else {
ZVAL_DEREF(var_ptr);
SEPARATE_ZVAL_NOREF(var_ptr);
binary_op(var_ptr, var_ptr, value TSRMLS_CC);
if (UNEXPECTED(RETURN_VALUE_USED(opline))) {
ZVAL_COPY(EX_VAR(opline->result.var), var_ptr);
}
}
if (UNEXPECTED(RETURN_VALUE_USED(opline))) {
ZVAL_COPY(EX_VAR(opline->result.var), var_ptr);
}
ZEND_VM_C_LABEL(assign_op_exit):
FREE_OP2();
FREE_OP1_VAR_PTR();
CHECK_EXCEPTION();
@ -688,7 +662,7 @@ ZEND_VM_HELPER_EX(zend_pre_incdec_property_helper, VAR|UNUSED|CV, CONST|TMP|VAR|
zval *object;
zval *property;
zval *retval;
int have_get_ptr = 0;
zval *zptr;
SAVE_OPLINE();
object = GET_OP1_OBJ_ZVAL_PTR_PTR(BP_VAR_RW);
@ -716,21 +690,17 @@ ZEND_VM_HELPER_EX(zend_pre_incdec_property_helper, VAR|UNUSED|CV, CONST|TMP|VAR|
/* here we are sure we are dealing with an object */
if (Z_OBJ_HT_P(object)->get_property_ptr_ptr) {
zval *zptr = Z_OBJ_HT_P(object)->get_property_ptr_ptr(object, property, BP_VAR_RW, ((OP2_TYPE == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL) TSRMLS_CC);
if (zptr != NULL) { /* NULL means no success in getting PTR */
ZVAL_DEREF(zptr);
SEPARATE_ZVAL_NOREF(zptr);
if (EXPECTED(Z_OBJ_HT_P(object)->get_property_ptr_ptr)
&& EXPECTED((zptr = Z_OBJ_HT_P(object)->get_property_ptr_ptr(object, property, BP_VAR_RW, ((OP2_TYPE == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL) TSRMLS_CC)) != NULL)) {
have_get_ptr = 1;
incdec_op(zptr);
if (RETURN_VALUE_USED(opline)) {
ZVAL_COPY(retval, zptr);
}
ZVAL_DEREF(zptr);
SEPARATE_ZVAL_NOREF(zptr);
incdec_op(zptr);
if (RETURN_VALUE_USED(opline)) {
ZVAL_COPY(retval, zptr);
}
}
if (!have_get_ptr) {
} else {
zval rv;
if (Z_OBJ_HT_P(object)->read_property && Z_OBJ_HT_P(object)->write_property) {
@ -783,7 +753,7 @@ ZEND_VM_HELPER_EX(zend_post_incdec_property_helper, VAR|UNUSED|CV, CONST|TMP|VAR
zval *object;
zval *property;
zval *retval;
int have_get_ptr = 0;
zval *zptr;
SAVE_OPLINE();
object = GET_OP1_OBJ_ZVAL_PTR_PTR(BP_VAR_RW);
@ -809,19 +779,15 @@ ZEND_VM_HELPER_EX(zend_post_incdec_property_helper, VAR|UNUSED|CV, CONST|TMP|VAR
/* here we are sure we are dealing with an object */
if (Z_OBJ_HT_P(object)->get_property_ptr_ptr) {
zval *zptr = Z_OBJ_HT_P(object)->get_property_ptr_ptr(object, property, BP_VAR_RW, ((OP2_TYPE == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL) TSRMLS_CC);
if (zptr != NULL) { /* NULL means no success in getting PTR */
have_get_ptr = 1;
ZVAL_DEREF(zptr);
ZVAL_COPY(retval, zptr);
if (EXPECTED(Z_OBJ_HT_P(object)->get_property_ptr_ptr)
&& EXPECTED((zptr = Z_OBJ_HT_P(object)->get_property_ptr_ptr(object, property, BP_VAR_RW, ((OP2_TYPE == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL) TSRMLS_CC)) != NULL)) {
SEPARATE_ZVAL_NOREF(zptr);
incdec_op(zptr);
}
}
ZVAL_DEREF(zptr);
ZVAL_COPY(retval, zptr);
if (!have_get_ptr) {
SEPARATE_ZVAL_NOREF(zptr);
incdec_op(zptr);
} else {
if (Z_OBJ_HT_P(object)->read_property && Z_OBJ_HT_P(object)->write_property) {
zval rv;
zval *z = Z_OBJ_HT_P(object)->read_property(object, property, BP_VAR_R, ((OP2_TYPE == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), &rv TSRMLS_CC);
@ -1161,9 +1127,6 @@ ZEND_VM_HELPER_EX(zend_fetch_var_address_helper, CONST|TMP|VAR|CV, UNUSED|CONST|
}
ZVAL_COPY(EX_VAR(opline->result.var), retval);
} else {
if (/*type == BP_VAR_W &&*/ (opline->extended_value & ZEND_FETCH_MAKE_REF)) {
ZVAL_MAKE_REF(retval);
}
ZVAL_INDIRECT(EX_VAR(opline->result.var), retval);
}
CHECK_EXCEPTION();
@ -1233,11 +1196,8 @@ ZEND_VM_HANDLER(84, ZEND_FETCH_DIM_W, VAR|CV, CONST|TMP|VAR|UNUSED|CV)
if (OP1_TYPE == IS_VAR && UNEXPECTED(container == NULL)) {
zend_error_noreturn(E_ERROR, "Cannot use string offset as an array");
}
if (EXPECTED(opline->extended_value == 0)) {
zend_fetch_dimension_address_W(EX_VAR(opline->result.var), container, GET_OP2_ZVAL_PTR_DEREF(BP_VAR_R), OP2_TYPE TSRMLS_CC);
} else {
zend_fetch_dimension_address_W_ref(EX_VAR(opline->result.var), container, GET_OP2_ZVAL_PTR_DEREF(BP_VAR_R), OP2_TYPE TSRMLS_CC);
}
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)) {
EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var));
@ -1259,6 +1219,7 @@ ZEND_VM_HANDLER(87, ZEND_FETCH_DIM_RW, VAR|CV, CONST|TMP|VAR|UNUSED|CV)
if (OP1_TYPE == IS_VAR && UNEXPECTED(container == NULL)) {
zend_error_noreturn(E_ERROR, "Cannot use string offset as an array");
}
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)) {
@ -1300,6 +1261,7 @@ ZEND_VM_HANDLER(93, ZEND_FETCH_DIM_FUNC_ARG, CONST|TMP|VAR|CV, CONST|TMP|VAR|UNU
if (OP1_TYPE == IS_VAR && UNEXPECTED(container == NULL)) {
zend_error_noreturn(E_ERROR, "Cannot use string offset as an array");
}
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)) {
EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var));
@ -1331,6 +1293,7 @@ ZEND_VM_HANDLER(96, ZEND_FETCH_DIM_UNSET, VAR|CV, CONST|TMP|VAR|CV)
if (OP1_TYPE == IS_VAR && UNEXPECTED(container == NULL)) {
zend_error_noreturn(E_ERROR, "Cannot use string offset as an array");
}
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)) {
@ -1389,7 +1352,7 @@ ZEND_VM_HANDLER(85, ZEND_FETCH_OBJ_W, VAR|UNUSED|CV, CONST|TMP|VAR|CV)
zend_error_noreturn(E_ERROR, "Cannot use string offset as an object");
}
zend_fetch_property_address(EX_VAR(opline->result.var), container, OP1_TYPE, property, ((OP2_TYPE == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_W, (opline->extended_value & ZEND_FETCH_MAKE_REF) != 0 TSRMLS_CC);
zend_fetch_property_address(EX_VAR(opline->result.var), container, OP1_TYPE, property, ((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)) {
EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var));
@ -1413,7 +1376,7 @@ ZEND_VM_HANDLER(88, ZEND_FETCH_OBJ_RW, VAR|UNUSED|CV, CONST|TMP|VAR|CV)
if (OP1_TYPE == IS_VAR && UNEXPECTED(container == NULL)) {
zend_error_noreturn(E_ERROR, "Cannot use string offset as an object");
}
zend_fetch_property_address(EX_VAR(opline->result.var), container, OP1_TYPE, property, ((OP2_TYPE == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_RW, 0 TSRMLS_CC);
zend_fetch_property_address(EX_VAR(opline->result.var), container, OP1_TYPE, property, ((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)) {
EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var));
@ -1475,7 +1438,7 @@ ZEND_VM_HANDLER(94, ZEND_FETCH_OBJ_FUNC_ARG, CONST|TMP|VAR|UNUSED|CV, CONST|TMP|
if (OP1_TYPE == IS_VAR && UNEXPECTED(container == NULL)) {
zend_error_noreturn(E_ERROR, "Cannot use string offset as an object");
}
zend_fetch_property_address(EX_VAR(opline->result.var), container, OP1_TYPE, property, ((OP2_TYPE == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_W, 0 TSRMLS_CC);
zend_fetch_property_address(EX_VAR(opline->result.var), container, OP1_TYPE, property, ((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)) {
EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var));
@ -1501,7 +1464,7 @@ ZEND_VM_HANDLER(97, ZEND_FETCH_OBJ_UNSET, VAR|UNUSED|CV, CONST|TMP|VAR|CV)
if (OP1_TYPE == IS_VAR && UNEXPECTED(container == NULL)) {
zend_error_noreturn(E_ERROR, "Cannot use string offset as an object");
}
zend_fetch_property_address(EX_VAR(opline->result.var), container, OP1_TYPE, property, ((OP2_TYPE == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_UNSET, 0 TSRMLS_CC);
zend_fetch_property_address(EX_VAR(opline->result.var), container, OP1_TYPE, property, ((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)) {
EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var));
@ -1579,29 +1542,33 @@ ZEND_VM_HANDLER(147, ZEND_ASSIGN_DIM, VAR|CV, CONST|TMP|VAR|UNUSED|CV)
if (OP1_TYPE == IS_VAR && UNEXPECTED(object_ptr == NULL)) {
zend_error_noreturn(E_ERROR, "Cannot use string offset as an array");
}
if (UNEXPECTED(Z_ISREF_P(object_ptr)) && Z_TYPE_P(Z_REFVAL_P(object_ptr)) == IS_OBJECT) {
object_ptr = Z_REFVAL_P(object_ptr);
}
if (Z_TYPE_P(object_ptr) == IS_OBJECT) {
ZVAL_DEREF(object_ptr);
if (UNEXPECTED(Z_TYPE_P(object_ptr) == IS_OBJECT)) {
zend_free_op free_op2;
zval *property_name = GET_OP2_ZVAL_PTR(BP_VAR_R);
zend_assign_to_object(RETURN_VALUE_USED(opline)?EX_VAR(opline->result.var):NULL, object_ptr, OP1_TYPE, property_name, (opline+1)->op1_type, &(opline+1)->op1, execute_data, ZEND_ASSIGN_DIM, ((OP2_TYPE == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property_name)) : NULL) TSRMLS_CC);
FREE_OP2();
} else {
zend_free_op free_op2, free_op_data1, free_op_data2;
zend_free_op free_op2, free_op_data1;
zval rv;
zval *value;
zval *dim = GET_OP2_ZVAL_PTR_DEREF(BP_VAR_R);
zval *variable_ptr;
variable_ptr = zend_fetch_dimension_address_W_str(EX_VAR((opline+1)->op2.var), object_ptr, dim, OP2_TYPE TSRMLS_CC);
FREE_OP2();
value = get_zval_ptr_deref((opline+1)->op1_type, &(opline+1)->op1, execute_data, &free_op_data1, BP_VAR_R);
if (UNEXPECTED(variable_ptr != NULL)) {
zend_assign_to_string_offset(variable_ptr, Z_LVAL_P(EX_VAR((opline+1)->op2.var)), value, (RETURN_VALUE_USED(opline) ? EX_VAR(opline->result.var) : NULL) TSRMLS_CC);
if (UNEXPECTED(Z_TYPE_P(object_ptr) == IS_STRING) &&
EXPECTED(Z_STRLEN_P(object_ptr) != 0)) {
zend_long offset = zend_fetch_string_offset(object_ptr, dim, BP_VAR_W TSRMLS_CC);
FREE_OP2();
value = get_zval_ptr_deref((opline+1)->op1_type, &(opline+1)->op1, execute_data, &free_op_data1, BP_VAR_R);
zend_assign_to_string_offset(object_ptr, offset, value, (RETURN_VALUE_USED(opline) ? EX_VAR(opline->result.var) : NULL) TSRMLS_CC);
FREE_OP(free_op_data1);
} else {
variable_ptr = _get_zval_ptr_ptr_var((opline+1)->op2.var, execute_data, &free_op_data2 TSRMLS_CC);
zend_fetch_dimension_address_W(&rv, object_ptr, dim, OP2_TYPE TSRMLS_CC);
FREE_OP2();
value = get_zval_ptr_deref((opline+1)->op1_type, &(opline+1)->op1, execute_data, &free_op_data1, BP_VAR_R);
ZEND_ASSERT(Z_TYPE(rv) == IS_INDIRECT);
variable_ptr = Z_INDIRECT(rv);
if (UNEXPECTED(variable_ptr == &EG(error_zval))) {
FREE_OP(free_op_data1);
if (RETURN_VALUE_USED(opline)) {
@ -1615,7 +1582,6 @@ ZEND_VM_HANDLER(147, ZEND_ASSIGN_DIM, VAR|CV, CONST|TMP|VAR|UNUSED|CV)
if (RETURN_VALUE_USED(opline)) {
ZVAL_COPY(EX_VAR(opline->result.var), value);
}
FREE_OP_VAR_PTR(free_op_data2);
}
}
}
@ -1669,10 +1635,13 @@ ZEND_VM_HANDLER(39, ZEND_ASSIGN_REF, VAR|CV, VAR|CV)
SAVE_OPLINE();
value_ptr = GET_OP2_ZVAL_PTR_PTR(BP_VAR_W);
if (OP2_TYPE == IS_VAR && UNEXPECTED(value_ptr == NULL)) {
zend_error_noreturn(E_ERROR, "Cannot create references to/from string offsets nor overloaded objects");
}
if (OP2_TYPE == IS_VAR &&
opline->extended_value == ZEND_RETURNS_FUNCTION &&
!(Z_VAR_FLAGS_P(value_ptr) & IS_VAR_RET_REF) &&
!Z_ISREF_P(value_ptr)) {
(value_ptr == &EG(uninitialized_zval) ||
(opline->extended_value == ZEND_RETURNS_FUNCTION &&
!(Z_VAR_FLAGS_P(value_ptr) & IS_VAR_RET_REF)))) {
if (!OP2_FREE) {
PZVAL_LOCK(value_ptr); /* undo the effect of get_zval_ptr_ptr() */
}
@ -1689,15 +1658,14 @@ ZEND_VM_HANDLER(39, ZEND_ASSIGN_REF, VAR|CV, VAR|CV)
}
variable_ptr = GET_OP1_ZVAL_PTR_PTR_UNDEF(BP_VAR_W);
if (OP1_TYPE == IS_VAR && UNEXPECTED(variable_ptr == NULL)) {
zend_error_noreturn(E_ERROR, "Cannot create references to/from string offsets nor overloaded objects");
}
if (OP1_TYPE == IS_VAR &&
UNEXPECTED(Z_TYPE_P(EX_VAR(opline->op1.var)) != IS_INDIRECT) &&
UNEXPECTED(!Z_ISREF_P(variable_ptr))) {
zend_error_noreturn(E_ERROR, "Cannot assign by reference to overloaded object");
}
if ((OP2_TYPE == IS_VAR && UNEXPECTED(value_ptr == NULL)) ||
(OP1_TYPE == IS_VAR && UNEXPECTED(variable_ptr == NULL))) {
zend_error_noreturn(E_ERROR, "Cannot create references to/from string offsets nor overloaded objects");
}
if ((OP1_TYPE == IS_VAR && UNEXPECTED(variable_ptr == &EG(error_zval))) ||
(OP2_TYPE == IS_VAR && UNEXPECTED(value_ptr == &EG(error_zval)))) {
variable_ptr = &EG(uninitialized_zval);
@ -2101,7 +2069,7 @@ ZEND_VM_HANDLER(109, ZEND_FETCH_CLASS, ANY, CONST|TMP|VAR|UNUSED|CV)
if (CACHED_PTR(Z_CACHE_SLOT_P(class_name))) {
Z_CE_P(EX_VAR(opline->result.var)) = CACHED_PTR(Z_CACHE_SLOT_P(class_name));
} else {
Z_CE_P(EX_VAR(opline->result.var)) = zend_fetch_class_by_name(Z_STR_P(class_name), opline->op2.zv + 1, opline->extended_value TSRMLS_CC);
Z_CE_P(EX_VAR(opline->result.var)) = zend_fetch_class_by_name(Z_STR_P(class_name), opline->op2.zv + 1, 0 TSRMLS_CC);
CACHE_PTR(Z_CACHE_SLOT_P(class_name), Z_CE_P(EX_VAR(opline->result.var)));
}
} else if (Z_TYPE_P(class_name) == IS_OBJECT) {
@ -2662,7 +2630,7 @@ ZEND_VM_HANDLER(60, ZEND_DO_FCALL, ANY, ANY)
zval *p = ZEND_CALL_ARG(call, 1);
for (i = 0; i < call->num_args; ++i) {
zend_verify_arg_type(fbc, i + 1, p, 0 TSRMLS_CC);
zend_verify_arg_type(fbc, i + 1, p TSRMLS_CC);
p++;
}
if (UNEXPECTED(EG(exception) != NULL)) {
@ -2862,10 +2830,10 @@ ZEND_VM_HANDLER(111, ZEND_RETURN_BY_REF, CONST|TMP|VAR|CV, ANY)
zend_error_noreturn(E_ERROR, "Cannot return string offsets by reference");
}
if (OP1_TYPE == IS_VAR && !Z_ISREF_P(retval_ptr)) {
if (opline->extended_value == ZEND_RETURNS_FUNCTION &&
(Z_VAR_FLAGS_P(retval_ptr) & IS_VAR_RET_REF)) {
} else {
if (OP1_TYPE == IS_VAR) {
if (retval_ptr == &EG(uninitialized_zval) ||
(opline->extended_value == ZEND_RETURNS_FUNCTION &&
!(Z_VAR_FLAGS_P(retval_ptr) & IS_VAR_RET_REF))) {
zend_error(E_NOTICE, "Only variable references should be returned by reference");
if (EX(return_value)) {
ZVAL_NEW_REF(EX(return_value), retval_ptr);
@ -3521,7 +3489,7 @@ ZEND_VM_HANDLER(63, ZEND_RECV, ANY, ANY)
} 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, opline->extended_value TSRMLS_CC);
zend_verify_arg_type(EX(func), arg_num, param TSRMLS_CC);
CHECK_EXCEPTION();
}
@ -3549,7 +3517,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, opline->extended_value TSRMLS_CC);
zend_verify_arg_type(EX(func), arg_num, param TSRMLS_CC);
}
CHECK_EXCEPTION();
@ -3574,7 +3542,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, opline->extended_value TSRMLS_CC);
zend_verify_arg_type(EX(func), arg_num, param TSRMLS_CC);
zend_hash_next_index_insert_new(Z_ARRVAL_P(params), param);
if (Z_REFCOUNTED_P(param)) Z_ADDREF_P(param);
param++;
@ -3667,23 +3635,38 @@ ZEND_VM_HANDLER(48, ZEND_CASE, CONST|TMP|VAR|CV, CONST|TMP|VAR|CV)
ZEND_VM_NEXT_OPCODE();
}
ZEND_VM_HANDLER(68, ZEND_NEW, ANY, ANY)
ZEND_VM_HANDLER(68, ZEND_NEW, CONST|VAR, ANY)
{
USE_OPLINE
zval object_zval;
zend_function *constructor;
zend_class_entry *ce;
SAVE_OPLINE();
if (UNEXPECTED((Z_CE_P(EX_VAR(opline->op1.var))->ce_flags & (ZEND_ACC_INTERFACE|ZEND_ACC_IMPLICIT_ABSTRACT_CLASS|ZEND_ACC_EXPLICIT_ABSTRACT_CLASS)) != 0)) {
if (Z_CE_P(EX_VAR(opline->op1.var))->ce_flags & ZEND_ACC_INTERFACE) {
zend_error_noreturn(E_ERROR, "Cannot instantiate interface %s", Z_CE_P(EX_VAR(opline->op1.var))->name->val);
} else if ((Z_CE_P(EX_VAR(opline->op1.var))->ce_flags & ZEND_ACC_TRAIT) == ZEND_ACC_TRAIT) {
zend_error_noreturn(E_ERROR, "Cannot instantiate trait %s", Z_CE_P(EX_VAR(opline->op1.var))->name->val);
if (OP1_TYPE == IS_CONST) {
if (CACHED_PTR(Z_CACHE_SLOT_P(opline->op1.zv))) {
ce = CACHED_PTR(Z_CACHE_SLOT_P(opline->op1.zv));
} else {
zend_error_noreturn(E_ERROR, "Cannot instantiate abstract class %s", Z_CE_P(EX_VAR(opline->op1.var))->name->val);
ce = zend_fetch_class_by_name(Z_STR_P(opline->op1.zv), opline->op1.zv + 1, 0 TSRMLS_CC);
if (UNEXPECTED(ce == NULL)) {
CHECK_EXCEPTION();
ZEND_VM_NEXT_OPCODE();
}
CACHE_PTR(Z_CACHE_SLOT_P(opline->op1.zv), ce);
}
} else {
ce = Z_CE_P(EX_VAR(opline->op1.var));
}
if (UNEXPECTED((ce->ce_flags & (ZEND_ACC_INTERFACE|ZEND_ACC_IMPLICIT_ABSTRACT_CLASS|ZEND_ACC_EXPLICIT_ABSTRACT_CLASS)) != 0)) {
if (ce->ce_flags & ZEND_ACC_INTERFACE) {
zend_error_noreturn(E_ERROR, "Cannot instantiate interface %s", ce->name->val);
} else if ((ce->ce_flags & ZEND_ACC_TRAIT) == ZEND_ACC_TRAIT) {
zend_error_noreturn(E_ERROR, "Cannot instantiate trait %s", ce->name->val);
} else {
zend_error_noreturn(E_ERROR, "Cannot instantiate abstract class %s", ce->name->val);
}
}
object_init_ex(&object_zval, Z_CE_P(EX_VAR(opline->op1.var)));
object_init_ex(&object_zval, ce);
constructor = Z_OBJ_HT(object_zval)->get_constructor(Z_OBJ(object_zval) TSRMLS_CC);
if (constructor == NULL) {
@ -3702,7 +3685,7 @@ ZEND_VM_HANDLER(68, ZEND_NEW, ANY, ANY)
ZEND_CALL_CTOR : (ZEND_CALL_CTOR | ZEND_CALL_CTOR_RESULT_UNUSED)),
constructor,
opline->extended_value,
Z_CE_P(EX_VAR(opline->op1.var)),
ce,
Z_OBJ(object_zval),
EX(call) TSRMLS_CC);
@ -3829,7 +3812,7 @@ ZEND_VM_HANDLER(99, ZEND_FETCH_CONSTANT, VAR|CONST|UNUSED, CONST)
} else if (CACHED_PTR(Z_CACHE_SLOT_P(opline->op1.zv))) {
ce = CACHED_PTR(Z_CACHE_SLOT_P(opline->op1.zv));
} else {
ce = zend_fetch_class_by_name(Z_STR_P(opline->op1.zv), opline->op1.zv + 1, opline->extended_value TSRMLS_CC);
ce = zend_fetch_class_by_name(Z_STR_P(opline->op1.zv), opline->op1.zv + 1, 0 TSRMLS_CC);
if (UNEXPECTED(EG(exception) != NULL)) {
HANDLE_EXCEPTION();
}
@ -5321,7 +5304,7 @@ ZEND_VM_HANDLER(105, ZEND_TICKS, ANY, ANY)
ZEND_VM_NEXT_OPCODE();
}
ZEND_VM_HANDLER(138, ZEND_INSTANCEOF, TMP|VAR|CV, ANY)
ZEND_VM_HANDLER(138, ZEND_INSTANCEOF, TMP|VAR|CV, CONST|VAR)
{
USE_OPLINE
zend_free_op free_op1;
@ -5332,7 +5315,25 @@ ZEND_VM_HANDLER(138, ZEND_INSTANCEOF, TMP|VAR|CV, ANY)
expr = GET_OP1_ZVAL_PTR_DEREF(BP_VAR_R);
if (Z_TYPE_P(expr) == IS_OBJECT) {
result = instanceof_function(Z_OBJCE_P(expr), Z_CE_P(EX_VAR(opline->op2.var)) TSRMLS_CC);
zend_class_entry *ce;
if (OP2_TYPE == IS_CONST) {
if (CACHED_PTR(Z_CACHE_SLOT_P(opline->op2.zv))) {
ce = CACHED_PTR(Z_CACHE_SLOT_P(opline->op2.zv));
} else {
ce = zend_fetch_class_by_name(Z_STR_P(opline->op2.zv), opline->op2.zv + 1, ZEND_FETCH_CLASS_NO_AUTOLOAD TSRMLS_CC);
if (UNEXPECTED(ce == NULL)) {
ZVAL_FALSE(EX_VAR(opline->result.var));
FREE_OP1();
CHECK_EXCEPTION();
ZEND_VM_NEXT_OPCODE();
}
CACHE_PTR(Z_CACHE_SLOT_P(opline->op2.zv), ce);
}
} else {
ce = Z_CE_P(EX_VAR(opline->op2.var));
}
result = instanceof_function(Z_OBJCE_P(expr), ce TSRMLS_CC);
} else {
result = 0;
}
@ -5362,7 +5363,7 @@ ZEND_VM_HANDLER(144, ZEND_ADD_INTERFACE, ANY, CONST)
if (CACHED_PTR(Z_CACHE_SLOT_P(opline->op2.zv))) {
iface = CACHED_PTR(Z_CACHE_SLOT_P(opline->op2.zv));
} else {
iface = zend_fetch_class_by_name(Z_STR_P(opline->op2.zv), opline->op2.zv + 1, opline->extended_value TSRMLS_CC);
iface = zend_fetch_class_by_name(Z_STR_P(opline->op2.zv), opline->op2.zv + 1, ZEND_FETCH_CLASS_INTERFACE TSRMLS_CC);
if (UNEXPECTED(iface == NULL)) {
CHECK_EXCEPTION();
ZEND_VM_NEXT_OPCODE();
@ -5391,7 +5392,7 @@ ZEND_VM_HANDLER(154, ZEND_ADD_TRAIT, ANY, ANY)
} else {
trait = zend_fetch_class_by_name(Z_STR_P(opline->op2.zv),
opline->op2.zv + 1,
opline->extended_value TSRMLS_CC);
ZEND_FETCH_CLASS_TRAIT TSRMLS_CC);
if (UNEXPECTED(trait == NULL)) {
CHECK_EXCEPTION();
ZEND_VM_NEXT_OPCODE();
@ -5686,9 +5687,10 @@ ZEND_VM_HANDLER(160, ZEND_YIELD, CONST|TMP|VAR|CV|UNUSED, CONST|TMP|VAR|CV|UNUSE
/* If a function call result is yielded and the function did
* not return by reference we throw a notice. */
if (OP1_TYPE == IS_VAR && !Z_ISREF_P(value_ptr)
&& !(opline->extended_value == ZEND_RETURNS_FUNCTION
&& (Z_VAR_FLAGS_P(value_ptr) & IS_VAR_RET_REF))) {
if (OP1_TYPE == IS_VAR &&
(value_ptr == &EG(uninitialized_zval) ||
(opline->extended_value == ZEND_RETURNS_FUNCTION &&
!(Z_VAR_FLAGS_P(value_ptr) & IS_VAR_RET_REF)))) {
zend_error(E_NOTICE, "Only variable references should be yielded by reference");
} else {
ZVAL_MAKE_REF(value_ptr);

File diff suppressed because it is too large Load diff

View file

@ -88,6 +88,9 @@ static const struct cv {
{ 0x00000000000c1084LLU, 0x46000000000000c0LLU },
#endif
"x-msi",
},
{ { 0, 0 },
NULL,
}
}, clsid2desc[] = {
{
@ -98,6 +101,9 @@ static const struct cv {
#endif
"MSI Installer",
},
{ { 0, 0 },
NULL,
}
};
private const char *

View file

@ -1798,7 +1798,7 @@ ZEND_FUNCTION(gmp_random)
Gets a random number in the range 0 to (2 ** n) - 1 */
ZEND_FUNCTION(gmp_random_bits)
{
long bits;
zend_long bits;
mpz_ptr gmpnum_result;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &bits) == FAILURE) {

View file

@ -616,7 +616,7 @@ static void zend_optimize_block(zend_code_block *block, zend_op_array *op_array,
VAR_SOURCE(opline->op1)->opcode == ZEND_QM_ASSIGN &&
ZEND_OP1_TYPE(VAR_SOURCE(opline->op1)) == IS_CONST &&
opline->opcode != ZEND_CASE && /* CASE _always_ expects variable */
opline->opcode != ZEND_FETCH_LIST && /* in 5.1, FETCH_DIM_TMP_VAR expects T */
opline->opcode != ZEND_FETCH_LIST &&
opline->opcode != ZEND_FE_RESET &&
opline->opcode != ZEND_FREE
) {

View file

@ -227,10 +227,16 @@ void zend_optimizer_compact_literals(zend_op_array *op_array, zend_optimizer_ctx
case ZEND_FETCH_CLASS:
case ZEND_ADD_INTERFACE:
case ZEND_ADD_TRAIT:
case ZEND_INSTANCEOF:
if (ZEND_OP2_TYPE(opline) == IS_CONST) {
LITERAL_INFO(opline->op2.constant, LITERAL_CLASS, 1, 1, 2);
}
break;
case ZEND_NEW:
if (ZEND_OP1_TYPE(opline) == IS_CONST) {
LITERAL_INFO(opline->op1.constant, LITERAL_CLASS, 1, 1, 2);
}
break;
case ZEND_ASSIGN_OBJ:
case ZEND_FETCH_OBJ_R:
case ZEND_FETCH_OBJ_W:

View file

@ -126,6 +126,7 @@ void zend_optimizer_update_op1_const(zend_op_array *op_array,
case ZEND_CATCH:
case ZEND_FETCH_CONSTANT:
case ZEND_DEFINED:
case ZEND_NEW:
opline->op1.constant = zend_optimizer_add_literal(op_array, val TSRMLS_CC);
zend_string_hash_val(Z_STR(ZEND_OP1_LITERAL(opline)));
Z_CACHE_SLOT(op_array->literals[opline->op1.constant]) = op_array->last_cache_slot++;
@ -173,6 +174,7 @@ void zend_optimizer_update_op2_const(zend_op_array *op_array,
case ZEND_ISSET_ISEMPTY_VAR:
case ZEND_ADD_INTERFACE:
case ZEND_ADD_TRAIT:
case ZEND_INSTANCEOF:
Z_CACHE_SLOT(op_array->literals[opline->op2.constant]) = op_array->last_cache_slot++;
zend_str_tolower(Z_STRVAL_P(val), Z_STRLEN_P(val));
zend_optimizer_add_literal(op_array, val TSRMLS_CC);

View file

@ -1130,10 +1130,6 @@ static zend_persistent_script *cache_script_in_shared_memory(zend_persistent_scr
return new_persistent_script;
}
if (!compact_persistent_script(new_persistent_script)) {
return new_persistent_script;
}
/* exclusive lock */
zend_shared_alloc_lock(TSRMLS_C);

View file

@ -88,64 +88,6 @@ zend_persistent_script* create_persistent_script(void)
return persistent_script;
}
static int compact_hash_table(HashTable *ht)
{
uint i = 3;
uint j;
uint nSize;
Bucket *d;
Bucket *p;
if (!ht->nNumOfElements || (ht->u.flags & HASH_FLAG_PACKED)) {
/* Empty tables don't allocate space for Buckets */
return 1;
}
if (ht->nNumOfElements >= 0x80000000) {
/* prevent overflow */
nSize = 0x80000000;
} else {
while ((1U << i) < ht->nNumOfElements) {
i++;
}
nSize = 1 << i;
}
if (nSize >= ht->nTableSize) {
/* Keep the size */
return 1;
}
d = (Bucket *)pemalloc(nSize * (sizeof(Bucket) + sizeof(uint32_t)), ht->u.flags & HASH_FLAG_PERSISTENT);
if (!d) {
return 0;
}
for (i = 0, j = 0; i < ht->nNumUsed; i++) {
p = ht->arData + i;
if (Z_TYPE(p->val) != IS_UNDEF) {
d[j++] = *p;
}
}
ht->nNumUsed = j;
pefree(ht->arData, ht->u.flags & HASH_FLAG_PERSISTENT);
ht->arData = d;
ht->arHash = (uint32_t *)(d + nSize);
ht->nTableSize = nSize;
ht->nTableMask = ht->nTableSize - 1;
zend_hash_rehash(ht);
return 1;
}
int compact_persistent_script(zend_persistent_script *persistent_script)
{
return compact_hash_table(&persistent_script->function_table) &&
compact_hash_table(&persistent_script->class_table);
}
void free_persistent_script(zend_persistent_script *persistent_script, int destroy_elements)
{
if (destroy_elements) {

View file

@ -28,7 +28,6 @@
void zend_accel_copy_internal_functions(TSRMLS_D);
zend_persistent_script* create_persistent_script(void);
int compact_persistent_script(zend_persistent_script *script);
void free_persistent_script(zend_persistent_script *persistent_script, int destroy_elements);
void zend_accel_free_user_functions(HashTable *ht TSRMLS_DC);

View file

@ -61,7 +61,6 @@ static int dblib_fetch_error(pdo_dbh_t *dbh, pdo_stmt_t *stmt, zval *info TSRMLS
msg, einfo->dberr, einfo->severity, stmt ? stmt->active_query_string : "");
add_next_index_long(info, einfo->dberr);
// TODO: avoid reallocation ???
add_next_index_string(info, message);
efree(message);
add_next_index_long(info, einfo->oserr);
@ -145,10 +144,12 @@ static zend_long dblib_handle_doer(pdo_dbh_t *dbh, const char *sql, zend_long sq
static int dblib_handle_quoter(pdo_dbh_t *dbh, const char *unquoted, int unquotedlen, char **quoted, int *quotedlen, enum pdo_param_type paramtype TSRMLS_DC)
{
pdo_dblib_db_handle *H = (pdo_dblib_db_handle *)dbh->driver_data;
/* pdo_dblib_db_handle *H = (pdo_dblib_db_handle *)dbh->driver_data; */
char *q;
int l = 1;
*quoted = q = safe_emalloc(2, unquotedlen, 3);
*q++ = '\'';
@ -174,7 +175,6 @@ static int dblib_handle_quoter(pdo_dbh_t *dbh, const char *unquoted, int unquote
static int pdo_dblib_transaction_cmd(const char *cmd, pdo_dbh_t *dbh TSRMLS_DC)
{
pdo_dblib_db_handle *H = (pdo_dblib_db_handle *)dbh->driver_data;
RETCODE ret;
if (FAIL == dbcmd(H->link, cmd)) {
return 0;
@ -246,6 +246,23 @@ char *dblib_handle_last_id(pdo_dbh_t *dbh, const char *name, unsigned int *len T
return id;
}
static int dblib_set_attr(pdo_dbh_t *dbh, zend_long attr, zval *val TSRMLS_DC)
{
switch(attr) {
case PDO_ATTR_TIMEOUT:
return 0;
default:
return 1;
}
}
static int dblib_get_attribute(pdo_dbh_t *dbh, zend_long attr, zval *return_value TSRMLS_DC)
{
/* dblib_handle *H = (pdo_pgsql_db_handle *)dbh->driver_data; */
return 0;
}
static struct pdo_dbh_methods dblib_methods = {
dblib_handle_closer,
dblib_handle_preparer,
@ -254,10 +271,10 @@ static struct pdo_dbh_methods dblib_methods = {
dblib_handle_begin, /* begin */
dblib_handle_commit, /* commit */
dblib_handle_rollback, /* rollback */
NULL, /*set attr */
dblib_set_attr, /*set attr */
dblib_handle_last_id, /* last insert id */
dblib_fetch_error, /* fetch error */
NULL, /* get attr */
dblib_get_attribute, /* get attr */
NULL, /* check liveness */
NULL, /* get driver methods */
NULL, /* request shutdown */
@ -303,6 +320,12 @@ static int pdo_dblib_handle_factory(pdo_dbh_t *dbh, zval *driver_options TSRMLS_
php_pdo_parse_data_source(dbh->data_source, dbh->data_source_len, vars, nvars);
if (driver_options) {
int timeout = pdo_attr_lval(driver_options, PDO_ATTR_TIMEOUT, 30 TSRMLS_CC);
dbsetlogintime(timeout); /* Connection/Login Timeout */
dbsettime(timeout); /* Statement Timeout */
}
H = pecalloc(1, sizeof(*H), dbh->is_persistent);
H->login = dblogin();
H->err.sqlstate = dbh->error_code;
@ -311,8 +334,8 @@ static int pdo_dblib_handle_factory(pdo_dbh_t *dbh, zval *driver_options TSRMLS_
goto cleanup;
}
DBERRHANDLE(H->login, (EHANDLEFUNC) error_handler);
DBMSGHANDLE(H->login, (MHANDLEFUNC) msg_handler);
DBERRHANDLE(H->login, (EHANDLEFUNC) pdo_dblib_error_handler);
DBMSGHANDLE(H->login, (MHANDLEFUNC) pdo_dblib_msg_handler);
if(vars[5].optval) {
for(i=0;i<nvers;i++) {

View file

@ -103,21 +103,15 @@ static int pdo_dblib_stmt_cursor_closer(pdo_stmt_t *stmt TSRMLS_DC)
/* Cancel any pending results */
dbcancel(H->link);
efree(stmt->columns);
stmt->columns = NULL;
return 1;
}
static int pdo_dblib_stmt_dtor(pdo_stmt_t *stmt TSRMLS_DC)
{
pdo_dblib_stmt *S = (pdo_dblib_stmt*)stmt->driver_data;
efree(stmt->columns);
stmt->columns = NULL;
efree(S);
return 1;
}
@ -128,16 +122,16 @@ static int pdo_dblib_stmt_next_rowset(pdo_stmt_t *stmt TSRMLS_DC)
RETCODE ret;
ret = dbresults(H->link);
if (FAIL == ret) {
pdo_raise_impl_error(stmt->dbh, stmt, "HY000", "PDO_DBLIB: dbresults() returned FAIL" TSRMLS_CC);
return 0;
}
if(NO_MORE_RESULTS == ret) {
return 0;
}
stmt->row_count = DBCOUNT(H->link);
stmt->column_count = dbnumcols(H->link);
@ -204,7 +198,7 @@ static int pdo_dblib_stmt_describe(pdo_stmt_t *stmt, int colno TSRMLS_DC)
struct pdo_column_data *col = &stmt->columns[colno];
col->name = (char*)dbcolname(H->link, colno+1);
col->name = estrdup(dbcolname(H->link, colno+1));
col->maxlen = dbcollen(H->link, colno+1);
col->namelen = strlen(col->name);
col->param_type = PDO_PARAM_STR;
@ -255,12 +249,11 @@ static int pdo_dblib_stmt_get_col(pdo_stmt_t *stmt, int colno, char **ptr,
break;
}
case SQLUNIQUE: {
*len = 36+1;
*len = 37;
tmp_ptr = emalloc(*len + 1);
/* uniqueidentifier is a 16-byte binary number, convert to 32 char hex string */
*len = dbconvert(NULL, SQLUNIQUE, *ptr, *len, SQLCHAR, tmp_ptr, *len);
php_strtoupper(tmp_ptr, *len);
tmp_ptr[36] = '\0';
*ptr = tmp_ptr;
break;
}

View file

@ -86,7 +86,7 @@ ZEND_GET_MODULE(pdo_dblib)
#endif
#endif
int error_handler(DBPROCESS *dbproc, int severity, int dberr,
int pdo_dblib_error_handler(DBPROCESS *dbproc, int severity, int dberr,
int oserr, char *dberrstr, char *oserrstr)
{
pdo_dblib_err *einfo;
@ -103,6 +103,7 @@ int error_handler(DBPROCESS *dbproc, int severity, int dberr,
einfo->severity = severity;
einfo->oserr = oserr;
einfo->dberr = dberr;
if (einfo->oserrstr) {
efree(einfo->oserrstr);
}
@ -128,16 +129,10 @@ int error_handler(DBPROCESS *dbproc, int severity, int dberr,
}
strcpy(einfo->sqlstate, state);
#if 0
php_error_docref(NULL TSRMLS_CC, E_WARNING,
"dblib error: %d %s (severity %d)",
dberr, dberrstr, severity);
#endif
return INT_CANCEL;
}
int msg_handler(DBPROCESS *dbproc, DBINT msgno, int msgstate,
int pdo_dblib_msg_handler(DBPROCESS *dbproc, DBINT msgno, int msgstate,
int severity, char *msgtext, char *srvname, char *procname, DBUSMALLINT line)
{
pdo_dblib_err *einfo;
@ -156,10 +151,6 @@ int msg_handler(DBPROCESS *dbproc, DBINT msgno, int msgstate,
einfo->lastmsg = estrdup(msgtext);
}
#if 0
php_error_docref(NULL TSRMLS_CC, E_WARNING, "dblib message: %s (severity %d)", msgtext, severity);
#endif
return 0;
}
@ -196,18 +187,9 @@ PHP_MINIT_FUNCTION(pdo_dblib)
return FAILURE;
}
/* TODO:
dbsetifile()
dbsetmaxprocs()
dbsetlogintime()
dbsettime()
*/
#if !PHP_DBLIB_IS_MSSQL
dberrhandle(error_handler);
dbmsghandle(msg_handler);
dberrhandle((EHANDLEFUNC) pdo_dblib_error_handler);
dbmsghandle((MHANDLEFUNC) pdo_dblib_msg_handler);
#endif
return SUCCESS;

View file

@ -37,7 +37,7 @@
# define DBSETOPT(a, b, c) dbsetopt(a, b, c)
# define SYBESMSG SQLESMSG
# define SYBESEOF SQLESEOF
# define SYBEFCON SQLECONN // SQLEFCON does not exist in MS SQL Server.
# define SYBEFCON SQLECONN /* SQLEFCON does not exist in MS SQL Server. */
# define SYBEMEM SQLEMEM
# define SYBEPWD SQLEPWD
@ -89,10 +89,10 @@ typedef unsigned char *LPBYTE;
typedef float DBFLT4;
#endif
int error_handler(DBPROCESS *dbproc, int severity, int dberr,
int pdo_dblib_error_handler(DBPROCESS *dbproc, int severity, int dberr,
int oserr, char *dberrstr, char *oserrstr);
int msg_handler(DBPROCESS *dbproc, DBINT msgno, int msgstate,
int pdo_dblib_msg_handler(DBPROCESS *dbproc, DBINT msgno, int msgstate,
int severity, char *msgtext, char *srvname, char *procname, DBUSMALLINT line);
extern pdo_driver_t pdo_dblib_driver;

View file

@ -3310,6 +3310,7 @@ static zend_op_array *phar_compile_file(zend_file_handle *file_handle, int type
zend_try {
failed = 0;
CG(zend_lineno) = 0;
res = phar_orig_compile_file(file_handle, type TSRMLS_CC);
} zend_catch {
failed = 1;

View file

@ -267,10 +267,8 @@ static zval *sxe_prop_dim_read(zval *object, zval *member, zend_bool elements, z
name = NULL;
} else {
if (Z_TYPE_P(member) != IS_STRING) {
tmp_zv = *member;
zval_copy_ctor(&tmp_zv);
ZVAL_STR(&tmp_zv, zval_get_string(member));
member = &tmp_zv;
convert_to_string(member);
}
name = Z_STRVAL_P(member);
}
@ -476,9 +474,7 @@ static int sxe_prop_dim_write(zval *object, zval *member, zval *value, zend_bool
}
} else {
if (Z_TYPE_P(member) != IS_STRING) {
trim_zv = *member;
zval_copy_ctor(&trim_zv);
convert_to_string(&trim_zv);
ZVAL_STR(&trim_zv, zval_get_string(member));
php_trim(Z_STRVAL(trim_zv), Z_STRLEN(trim_zv), NULL, 0, &tmp_zv, 3 TSRMLS_CC);
zval_dtor(&trim_zv);
member = &tmp_zv;
@ -736,10 +732,8 @@ static int sxe_prop_dim_exists(zval *object, zval *member, int check_empty, zend
zval tmp_zv;
if (Z_TYPE_P(member) != IS_STRING && Z_TYPE_P(member) != IS_LONG) {
tmp_zv = *member;
zval_copy_ctor(&tmp_zv);
ZVAL_STR(&tmp_zv, zval_get_string(member));
member = &tmp_zv;
convert_to_string(member);
}
sxe = Z_SXEOBJ_P(object);
@ -866,10 +860,8 @@ static void sxe_prop_dim_delete(zval *object, zval *member, zend_bool elements,
int test = 0;
if (Z_TYPE_P(member) != IS_STRING && Z_TYPE_P(member) != IS_LONG) {
tmp_zv = *member;
zval_copy_ctor(&tmp_zv);
ZVAL_STR(&tmp_zv, zval_get_string(member));
member = &tmp_zv;
convert_to_string(member);
}
sxe = Z_SXEOBJ_P(object);

View file

@ -834,13 +834,10 @@ static xmlNodePtr to_xml_string(encodeTypePtr type, zval *data, int style, xmlNo
str = estrndup(Z_STRVAL_P(data), Z_STRLEN_P(data));
new_len = Z_STRLEN_P(data);
} else {
zval tmp = *data;
zval_copy_ctor(&tmp);
convert_to_string(&tmp);
str = estrndup(Z_STRVAL(tmp), Z_STRLEN(tmp));
new_len = Z_STRLEN(tmp);
zval_dtor(&tmp);
zend_string *tmp = zval_get_string(data);
str = estrndup(tmp->val, tmp->len);
new_len = tmp->len;
zend_string_release(tmp);
}
if (SOAP_GLOBAL(encoding) != NULL) {
@ -953,9 +950,7 @@ static xmlNodePtr to_xml_hexbin(encodeTypePtr type, zval *data, int style, xmlNo
FIND_ZVAL_NULL(data, ret, style);
if (Z_TYPE_P(data) != IS_STRING) {
tmp = *data;
zval_copy_ctor(&tmp);
convert_to_string(&tmp);
ZVAL_STR(&tmp, zval_get_string(data));
data = &tmp;
}
str = (unsigned char *) safe_emalloc(Z_STRLEN_P(data) * 2, sizeof(char), 1);
@ -1063,9 +1058,9 @@ static xmlNodePtr to_xml_long(encodeTypePtr type, zval *data, int style, xmlNode
snprintf(s, sizeof(s), "%0.0F",floor(Z_DVAL_P(data)));
xmlNodeSetContent(ret, BAD_CAST(s));
} else {
zval tmp = *data;
zval tmp;
zval_copy_ctor(&tmp);
ZVAL_DUP(&tmp, data);
if (Z_TYPE(tmp) != IS_LONG) {
convert_to_long(&tmp);
}
@ -1090,11 +1085,7 @@ static xmlNodePtr to_xml_double(encodeTypePtr type, zval *data, int style, xmlNo
xmlAddChild(parent, ret);
FIND_ZVAL_NULL(data, ret, style);
tmp = *data;
if (Z_TYPE(tmp) != IS_DOUBLE) {
zval_copy_ctor(&tmp);
convert_to_double(&tmp);
}
ZVAL_DOUBLE(&tmp, zval_get_double(data));
str = (char *) safe_emalloc(EG(precision), 1, MAX_LENGTH_OF_DOUBLE + 1);
php_gcvt(Z_DVAL(tmp), EG(precision), '.', 'E', str);
@ -3032,13 +3023,12 @@ static xmlNodePtr to_xml_list(encodeTypePtr enc, zval *data, int style, xmlNodeP
xmlNodeSetContentLen(ret, BAD_CAST(list.s->val), list.s->len);
smart_str_free(&list);
} else {
zval tmp = *data;
zval tmp;
char *str, *start, *next;
smart_str list = {0};
if (Z_TYPE_P(data) != IS_STRING) {
zval_copy_ctor(&tmp);
convert_to_string(&tmp);
ZVAL_STR(&tmp, zval_get_string(data));
data = &tmp;
}
str = estrndup(Z_STRVAL_P(data), Z_STRLEN_P(data));
@ -3144,10 +3134,9 @@ static xmlNodePtr to_xml_any(encodeTypePtr type, zval *data, int style, xmlNodeP
if (Z_TYPE_P(data) == IS_STRING) {
ret = xmlNewTextLen(BAD_CAST(Z_STRVAL_P(data)), Z_STRLEN_P(data));
} else {
zval tmp = *data;
zval tmp;
zval_copy_ctor(&tmp);
convert_to_string(&tmp);
ZVAL_STR(&tmp, zval_get_string(data));
ret = xmlNewTextLen(BAD_CAST(Z_STRVAL(tmp)), Z_STRLEN(tmp));
zval_dtor(&tmp);
}

View file

@ -351,7 +351,9 @@ PHP_FUNCTION(spl_autoload)
while (ex && (!ex->func || !ZEND_USER_CODE(ex->func->type))) {
ex = ex->prev_execute_data;
}
if (ex && ex->opline->opcode != ZEND_FETCH_CLASS) {
if (ex &&
ex->opline->opcode != ZEND_FETCH_CLASS &&
ex->opline->opcode != ZEND_NEW) {
zend_throw_exception_ex(spl_ce_LogicException, 0 TSRMLS_CC, "Class %s could not be loaded", class_name->val);
} else {
php_error_docref(NULL TSRMLS_CC, E_ERROR, "Class %s could not be loaded", class_name->val);

View file

@ -728,7 +728,7 @@ static int php_array_user_key_compare(const void *a, const void *b TSRMLS_DC) /*
zval_ptr_dtor(&args[0]);
zval_ptr_dtor(&args[1]);
return result;
return result < 0 ? -1 : result > 0 ? 1 : 0;
}
/* }}} */
@ -1301,9 +1301,10 @@ PHP_FUNCTION(array_search)
}
/* }}} */
static int php_valid_var_name(char *var_name, int var_name_len) /* {{{ */
static int php_valid_var_name(char *var_name, size_t var_name_len) /* {{{ */
{
int i, ch;
size_t i;
int ch;
if (!var_name || !var_name_len) {
return 0;
@ -1337,7 +1338,7 @@ static int php_valid_var_name(char *var_name, int var_name_len) /* {{{ */
}
/* }}} */
PHPAPI int php_prefix_varname(zval *result, zval *prefix, char *var_name, int var_name_len, zend_bool add_underscore TSRMLS_DC) /* {{{ */
PHPAPI int php_prefix_varname(zval *result, zval *prefix, char *var_name, size_t var_name_len, zend_bool add_underscore TSRMLS_DC) /* {{{ */
{
ZVAL_NEW_STR(result, zend_string_alloc(Z_STRLEN_P(prefix) + (add_underscore ? 1 : 0) + var_name_len, 0));
memcpy(Z_STRVAL_P(result), Z_STRVAL_P(prefix), Z_STRLEN_P(prefix));
@ -1569,7 +1570,7 @@ PHP_FUNCTION(array_fill)
}
/* allocate an array for return */
array_init_size(return_value, num);
array_init_size(return_value, (uint32_t)num);
if (num == 0) {
return;
@ -1786,10 +1787,10 @@ err:
static void php_array_data_shuffle(zval *array TSRMLS_DC) /* {{{ */
{
uint idx;
uint32_t idx, j, n_elems;
Bucket *p, temp;
HashTable *hash;
int j, n_elems, rnd_idx, n_left;
zend_long rnd_idx, n_left;
n_elems = zend_hash_num_elements(Z_ARRVAL_P(array));
@ -2222,7 +2223,7 @@ PHP_FUNCTION(array_splice)
/* Don't create the array of removed elements if it's not going
* to be used; e.g. only removing and/or replacing elements */
if (USED_RET()) {
int size = length;
zend_long size = length;
/* Clamp the offset.. */
if (offset > num_in) {
@ -2234,17 +2235,17 @@ PHP_FUNCTION(array_splice)
/* ..and the length */
if (length < 0) {
size = num_in - offset + length;
} else if (((zend_ulong) offset + (zend_ulong) length) > (unsigned) num_in) {
} else if (((zend_ulong) offset + (zend_ulong) length) > (uint32_t) num_in) {
size = num_in - offset;
}
/* Initialize return value */
array_init_size(return_value, size > 0 ? size : 0);
array_init_size(return_value, size > 0 ? (uint32_t)size : 0);
rem_hash = Z_ARRVAL_P(return_value);
}
/* Perform splice */
new_hash = php_splice(Z_ARRVAL_P(array), offset, length, repl, repl_num, rem_hash);
new_hash = php_splice(Z_ARRVAL_P(array), (int)offset, (int)length, repl, (int)repl_num, rem_hash);
/* Replace input array's hashtable with the new one */
old_hash = *Z_ARRVAL_P(array);
@ -2314,7 +2315,7 @@ PHP_FUNCTION(array_slice)
}
/* Initialize returned array */
array_init_size(return_value, length > 0 ? length : 0);
array_init_size(return_value, length > 0 ? (uint32_t)length : 0);
if (length <= 0) {
return;
@ -2897,9 +2898,9 @@ PHP_FUNCTION(array_pad)
/* Pad on the right or on the left */
if (pad_size > 0) {
new_hash = php_splice(Z_ARRVAL_P(return_value), input_size, 0, pads, num_pads, NULL);
new_hash = php_splice(Z_ARRVAL_P(return_value), (int)input_size, 0, pads, (int)num_pads, NULL);
} else {
new_hash = php_splice(Z_ARRVAL_P(return_value), 0, 0, pads, num_pads, NULL);
new_hash = php_splice(Z_ARRVAL_P(return_value), 0, 0, pads, (int)num_pads, NULL);
}
/* Copy the result hash into return value */
@ -3971,22 +3972,23 @@ PHPAPI int php_multisort_compare(const void *a, const void *b TSRMLS_DC) /* {{{
Bucket *ab = *(Bucket **)a;
Bucket *bb = *(Bucket **)b;
int r;
int result = 0;
zend_long result;
zval temp;
r = 0;
do {
php_set_compare_func(ARRAYG(multisort_flags)[MULTISORT_TYPE][r] TSRMLS_CC);
ARRAYG(compare_func)(&temp, &ab[r].val, &bb[r].val TSRMLS_CC);
result = ARRAYG(multisort_flags)[MULTISORT_ORDER][r] * Z_LVAL(temp);
if (result != 0) {
return result;
return result > 0 ? 1 : -1;
}
r++;
} while (Z_TYPE(ab[r].val) != IS_UNDEF);
return result;
return 0;
}
/* }}} */
@ -4077,7 +4079,7 @@ PHP_FUNCTION(array_multisort)
/* flag allowed here */
if (parse_state[MULTISORT_TYPE] == 1) {
/* Save the flag and make sure then next arg is not the current flag. */
sort_type = Z_LVAL(args[i]);
sort_type = (int)Z_LVAL(args[i]);
parse_state[MULTISORT_TYPE] = 0;
} else {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Argument #%d is expected to be an array or sorting flag that has not already been specified", i + 1);
@ -4205,7 +4207,7 @@ PHP_FUNCTION(array_rand)
/* Make the return value an array only if we need to pass back more than one result. */
if (num_req > 1) {
array_init_size(return_value, num_req);
array_init_size(return_value, (uint32_t)num_req);
}
/* We can't use zend_hash_index_find() because the array may have string keys or gaps. */
@ -4690,14 +4692,14 @@ PHP_FUNCTION(array_chunk)
size = num_in > 0 ? num_in : 1;
}
array_init_size(return_value, ((num_in - 1) / size) + 1);
array_init_size(return_value, (uint32_t)(((num_in - 1) / size) + 1));
ZVAL_UNDEF(&chunk);
ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(input), num_key, str_key, entry) {
/* If new chunk, create and initialize it. */
if (Z_TYPE(chunk) == IS_UNDEF) {
array_init_size(&chunk, size);
array_init_size(&chunk, (uint32_t)size);
}
/* Add entry to the chunk, preserving keys if necessary. */

View file

@ -25,12 +25,12 @@
/* }}} */
ZEND_BEGIN_MODULE_GLOBALS(assert)
zend_long active;
zend_long bail;
zend_long warning;
zend_long quiet_eval;
zval callback;
char *cb;
zend_bool active;
zend_bool bail;
zend_bool warning;
zend_bool quiet_eval;
ZEND_END_MODULE_GLOBALS(assert)
ZEND_DECLARE_MODULE_GLOBALS(assert)
@ -78,11 +78,11 @@ static PHP_INI_MH(OnChangeCallback) /* {{{ */
/* }}} */
PHP_INI_BEGIN()
STD_PHP_INI_ENTRY("assert.active", "1", PHP_INI_ALL, OnUpdateLong, active, zend_assert_globals, assert_globals)
STD_PHP_INI_ENTRY("assert.bail", "0", PHP_INI_ALL, OnUpdateLong, bail, zend_assert_globals, assert_globals)
STD_PHP_INI_ENTRY("assert.warning", "1", PHP_INI_ALL, OnUpdateLong, warning, zend_assert_globals, assert_globals)
STD_PHP_INI_ENTRY("assert.active", "1", PHP_INI_ALL, OnUpdateBool, active, zend_assert_globals, assert_globals)
STD_PHP_INI_ENTRY("assert.bail", "0", PHP_INI_ALL, OnUpdateBool, bail, zend_assert_globals, assert_globals)
STD_PHP_INI_ENTRY("assert.warning", "1", PHP_INI_ALL, OnUpdateBool, warning, zend_assert_globals, assert_globals)
PHP_INI_ENTRY("assert.callback", NULL, PHP_INI_ALL, OnChangeCallback)
STD_PHP_INI_ENTRY("assert.quiet_eval", "0", PHP_INI_ALL, OnUpdateLong, quiet_eval, zend_assert_globals, assert_globals)
STD_PHP_INI_ENTRY("assert.quiet_eval", "0", PHP_INI_ALL, OnUpdateBool, quiet_eval, zend_assert_globals, assert_globals)
PHP_INI_END()
static void php_assert_init_globals(zend_assert_globals *assert_globals_p TSRMLS_DC) /* {{{ */
@ -258,7 +258,7 @@ PHP_FUNCTION(assert_options)
{
zval *value = NULL;
zend_long what;
int oldint;
zend_bool oldint;
int ac = ZEND_NUM_ARGS();
zend_string *key;

View file

@ -3952,7 +3952,7 @@ PHP_FUNCTION(long2ip)
/* "It's a long but it's not, PHP ints are signed */
char *ip;
size_t ip_len;
zend_ulong n;
uint32_t n;
struct in_addr myaddr;
#ifdef HAVE_INET_PTON
char str[40];
@ -4076,7 +4076,7 @@ PHP_FUNCTION(putenv)
#endif
}
pe.key_len = strlen(pe.key);
pe.key_len = (int)strlen(pe.key);
#ifdef PHP_WIN32
if (equals) {
if (pe.key_len < setting_len - 1) {
@ -4289,7 +4289,7 @@ PHP_FUNCTION(getopt)
opts->need_param = 0;
opts->opt_name = estrdup(arg_str->val);
len = strlen(opts->opt_name);
len = (int)strlen(opts->opt_name);
if ((len > 0) && (opts->opt_name[len - 1] == ':')) {
opts->need_param++;
opts->opt_name[len - 1] = '\0';
@ -4345,7 +4345,7 @@ PHP_FUNCTION(getopt)
}
/* Add this option / argument pair to the result hash. */
optname_len = strlen(optname);
optname_len = (int)strlen(optname);
if (!(optname_len > 1 && optname[0] == '0') && is_numeric_string(optname, optname_len, NULL, NULL, 0) == IS_LONG) {
/* numeric string */
int optname_int = atoi(optname);
@ -4400,9 +4400,9 @@ PHP_FUNCTION(sleep)
RETURN_FALSE;
}
#ifdef PHP_SLEEP_NON_VOID
RETURN_LONG(php_sleep(num));
RETURN_LONG(php_sleep((unsigned int)num));
#else
php_sleep(num);
php_sleep((unsigned int)num);
#endif
}
@ -4422,7 +4422,7 @@ PHP_FUNCTION(usleep)
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Number of microseconds must be greater than or equal to 0");
RETURN_FALSE;
}
usleep(num);
usleep((unsigned int)num);
#endif
}
/* }}} */
@ -4449,7 +4449,7 @@ PHP_FUNCTION(time_nanosleep)
}
php_req.tv_sec = (time_t) tv_sec;
php_req.tv_nsec = tv_nsec;
php_req.tv_nsec = (long)tv_nsec;
if (!nanosleep(&php_req, &php_rem)) {
RETURN_TRUE;
} else if (errno == EINTR) {
@ -4554,7 +4554,7 @@ PHP_FUNCTION(get_cfg_var)
return;
}
retval = cfg_get_entry(varname, varname_len);
retval = cfg_get_entry(varname, (uint)varname_len);
if (retval) {
if (Z_TYPE_P(retval) == IS_ARRAY) {
@ -4637,7 +4637,7 @@ PHP_FUNCTION(error_log)
}
if (argc > 1) {
opt_err = erropt;
opt_err = (int)erropt;
}
if (_php_error_log_ex(opt_err, message, message_len, opt, headers TSRMLS_CC) == FAILURE) {
@ -4655,7 +4655,7 @@ PHPAPI int _php_error_log(int opt_err, char *message, char *opt, char *headers T
}
/* }}} */
PHPAPI int _php_error_log_ex(int opt_err, char *message, int message_len, char *opt, char *headers TSRMLS_DC) /* {{{ */
PHPAPI int _php_error_log_ex(int opt_err, char *message, size_t message_len, char *opt, char *headers TSRMLS_DC) /* {{{ */
{
php_stream *stream = NULL;
@ -5212,7 +5212,7 @@ PHP_FUNCTION(ini_get)
return;
}
str = zend_ini_string(varname, varname_len, 0);
str = zend_ini_string(varname, (uint)varname_len, 0);
if (!str) {
RETURN_FALSE;
@ -5322,7 +5322,7 @@ PHP_FUNCTION(ini_set)
return;
}
old_value = zend_ini_string(varname->val, varname->len, 0);
old_value = zend_ini_string(varname->val, (int)varname->len, 0);
/* copy to return here, because alter might free it! */
if (old_value) {
@ -5331,7 +5331,7 @@ PHP_FUNCTION(ini_set)
RETVAL_FALSE;
}
#define _CHECK_PATH(var, var_len, ini) php_ini_check_path(var, var_len, ini, sizeof(ini))
#define _CHECK_PATH(var, var_len, ini) php_ini_check_path(var, (int)var_len, ini, sizeof(ini))
/* open basedir check */
if (PG(open_basedir)) {
if (_CHECK_PATH(varname->val, varname->len, "error_log") ||
@ -5592,7 +5592,7 @@ PHP_FUNCTION(getprotobynumber)
return;
}
ent = getprotobynumber(proto);
ent = getprotobynumber((int)proto);
if (ent == NULL) {
RETURN_FALSE;
@ -5790,7 +5790,7 @@ static void php_simple_ini_parser_cb(zval *arg1, zval *arg2, zval *arg3, int cal
}
if (!(Z_STRLEN_P(arg1) > 1 && Z_STRVAL_P(arg1)[0] == '0') && is_numeric_string(Z_STRVAL_P(arg1), Z_STRLEN_P(arg1), NULL, NULL, 0) == IS_LONG) {
zend_ulong key = (zend_ulong) zend_atol(Z_STRVAL_P(arg1), Z_STRLEN_P(arg1));
zend_ulong key = (zend_ulong) zend_atol(Z_STRVAL_P(arg1), (int)Z_STRLEN_P(arg1));
if ((find_hash = zend_hash_index_find(Z_ARRVAL_P(arr), key)) == NULL) {
array_init(&hash);
find_hash = zend_hash_index_update(Z_ARRVAL_P(arr), key, &hash);
@ -5878,7 +5878,7 @@ PHP_FUNCTION(parse_ini_file)
fh.type = ZEND_HANDLE_FILENAME;
array_init(return_value);
if (zend_parse_ini_file(&fh, 0, scanner_mode, ini_parser_cb, return_value TSRMLS_CC) == FAILURE) {
if (zend_parse_ini_file(&fh, 0, (int)scanner_mode, ini_parser_cb, return_value TSRMLS_CC) == FAILURE) {
zval_dtor(return_value);
RETURN_FALSE;
}
@ -5917,7 +5917,7 @@ PHP_FUNCTION(parse_ini_string)
memset(string + str_len, 0, ZEND_MMAP_AHEAD);
array_init(return_value);
if (zend_parse_ini_string(string, 0, scanner_mode, ini_parser_cb, return_value TSRMLS_CC) == FAILURE) {
if (zend_parse_ini_string(string, 0, (int)scanner_mode, ini_parser_cb, return_value TSRMLS_CC) == FAILURE) {
zval_dtor(return_value);
RETVAL_FALSE;
}

View file

@ -142,8 +142,8 @@ PHP_RSHUTDOWN_FUNCTION(browscap);
/* Left for BC (not binary safe!) */
PHPAPI int _php_error_log(int opt_err, char *message, char *opt, char *headers TSRMLS_DC);
PHPAPI int _php_error_log_ex(int opt_err, char *message, int message_len, char *opt, char *headers TSRMLS_DC);
PHPAPI int php_prefix_varname(zval *result, zval *prefix, char *var_name, int var_name_len, zend_bool add_underscore TSRMLS_DC);
PHPAPI int _php_error_log_ex(int opt_err, char *message, size_t message_len, char *opt, char *headers TSRMLS_DC);
PHPAPI int php_prefix_varname(zval *result, zval *prefix, char *var_name, size_t var_name_len, zend_bool add_underscore TSRMLS_DC);
#if SIZEOF_INT == 4
/* Most 32-bit and 64-bit systems have 32-bit ints */

View file

@ -295,7 +295,7 @@ PHP_FUNCTION(crypt)
}
salt[salt_in_len] = '\0';
if ((result = php_crypt(str, str_len, salt, salt_in_len)) == NULL) {
if ((result = php_crypt(str, (int)str_len, salt, (int)salt_in_len)) == NULL) {
if (salt[0] == '*' && salt[1] == '0') {
RETURN_STRING("*1");
} else {

View file

@ -120,7 +120,7 @@ static void sha256_process_block (const void *buffer, size_t len, struct sha256_
/* First increment the byte count. FIPS 180-2 specifies the possible
length of the file up to 2^64 bits. Here we only compute the
number of bytes. Do a double word increment. */
ctx->total[0] += len;
ctx->total[0] += (uint32_t)len;
if (ctx->total[0] < len) {
++ctx->total[1];
}
@ -261,7 +261,7 @@ static void sha256_process_bytes(const void *buffer, size_t len, struct sha256_c
size_t add = 128 - left_over > len ? len : 128 - left_over;
memcpy(&ctx->buffer[left_over], buffer, add);
ctx->buflen += add;
ctx->buflen += (uint32_t)add;
if (ctx->buflen > 64) {
sha256_process_block(ctx->buffer, ctx->buflen & ~63, ctx);
@ -306,7 +306,7 @@ compilers don't. */
left_over -= 64;
memcpy(ctx->buffer, &ctx->buffer[64], left_over);
}
ctx->buflen = left_over;
ctx->buflen = (uint32_t)left_over;
}
}
@ -529,7 +529,7 @@ char * php_sha256_crypt_r(const char *key, const char *salt, char *buffer, int b
}
cp = __php_stpncpy(cp, salt, MIN ((size_t) MAX (0, buflen), salt_len));
buflen -= MIN((size_t) MAX (0, buflen), salt_len);
buflen -= MIN(MAX (0, buflen), (int)salt_len);
if (buflen > 0) {
*cp++ = '$';
@ -600,7 +600,7 @@ char * php_sha256_crypt(const char *key, const char *salt)
static int buflen;
int needed = (sizeof(sha256_salt_prefix) - 1
+ sizeof(sha256_rounds_prefix) + 9 + 1
+ strlen(salt) + 1 + 43 + 1);
+ (int)strlen(salt) + 1 + 43 + 1);
if (buflen < needed) {
char *new_buffer = (char *) realloc(buffer, needed);

View file

@ -87,7 +87,7 @@ static zend_class_entry *dir_class_entry_ptr;
} \
ZEND_FETCH_RESOURCE(dirp, php_stream *, tmp, -1, "Directory", php_file_le_stream()); \
} else { \
ZEND_FETCH_RESOURCE(dirp, php_stream *, 0, DIRG(default_dir)->handle, "Directory", php_file_le_stream()); \
ZEND_FETCH_RESOURCE(dirp, php_stream *, 0, (int)DIRG(default_dir)->handle, "Directory", php_file_le_stream()); \
} \
} else { \
dirp = (php_stream *) zend_fetch_resource(id TSRMLS_CC, -1, "Directory", NULL, 1, php_file_le_stream()); \
@ -463,7 +463,7 @@ PHP_FUNCTION(glob)
cwd[2] = '\0';
}
#endif
cwd_skip = strlen(cwd)+1;
cwd_skip = (int)strlen(cwd)+1;
snprintf(work_pattern, MAXPATHLEN, "%s%c%s", cwd, DEFAULT_SLASH, pattern);
pattern = work_pattern;

View file

@ -129,7 +129,7 @@ PHPAPI int php_load_extension(char *filename, int type, int start_now TSRMLS_DC)
}
libpath = estrdup(filename);
} else if (extension_dir && extension_dir[0]) {
int extension_dir_len = strlen(extension_dir);
int extension_dir_len = (int)strlen(extension_dir);
if (IS_SLASH(extension_dir[extension_dir_len-1])) {
spprintf(&libpath, 0, "%s%s", extension_dir, filename); /* SAFE */

View file

@ -208,7 +208,7 @@ static void php_parserr(PDNS_RECORD pRec, int type_to_fetch, int store, int raw,
DWORD count = data_txt->dwStringCount;
zend_string *txt;
char *txt_dst;
long txt_len = 0;
size_t txt_len = 0;
zval entries;
add_assoc_string(subarray, "type", "TXT");
@ -222,7 +222,7 @@ static void php_parserr(PDNS_RECORD pRec, int type_to_fetch, int store, int raw,
txt = zend_string_safe_alloc(txt_len, 2, 0, 0);
txt_dst = txt->val;
for (i = 0; i < count; i++) {
int len = strlen(data_txt->pStringArray[i]);
size_t len = strlen(data_txt->pStringArray[i]);
memcpy(txt_dst, data_txt->pStringArray[i], len);
add_next_index_stringl(&entries, data_txt->pStringArray[i], len);
txt_dst += len;

View file

@ -61,7 +61,8 @@ PHPAPI int php_exec(int type, char *cmd, zval *array, zval *return_value TSRMLS_
{
FILE *fp;
char *buf;
int l = 0, pclose_return;
size_t l = 0;
int pclose_return;
char *b, *d=NULL;
php_stream *stream;
size_t buflen, bufl = 0;
@ -115,8 +116,8 @@ PHPAPI int php_exec(int type, char *cmd, zval *array, zval *return_value TSRMLS_
} else if (type == 2) {
/* strip trailing whitespaces */
l = bufl;
while (l-- && isspace(((unsigned char *)buf)[l]));
if (l != (int)(bufl - 1)) {
while (l >= 1 && l-- && isspace(((unsigned char *)buf)[l]));
if (l != (bufl - 1)) {
bufl = l + 1;
buf[bufl] = '\0';
}
@ -128,8 +129,8 @@ PHPAPI int php_exec(int type, char *cmd, zval *array, zval *return_value TSRMLS_
/* strip trailing whitespaces if we have not done so already */
if ((type == 2 && buf != b) || type != 2) {
l = bufl;
while (l-- && isspace(((unsigned char *)buf)[l]));
if (l != (int)(bufl - 1)) {
while (l >= 1 && l-- && isspace(((unsigned char *)buf)[l]));
if (l != (bufl - 1)) {
bufl = l + 1;
buf[bufl] = '\0';
}
@ -240,7 +241,7 @@ PHP_FUNCTION(passthru)
*/
PHPAPI zend_string *php_escape_shell_cmd(char *str)
{
register int x, y, l = strlen(str);
register int x, y, l = (int)strlen(str);
char *p = NULL;
size_t estimate = (2 * l) + 1;
zend_string *cmd;
@ -333,7 +334,7 @@ PHPAPI zend_string *php_escape_shell_cmd(char *str)
*/
PHPAPI zend_string *php_escape_shell_arg(char *str)
{
int x, y = 0, l = strlen(str);
int x, y = 0, l = (int)strlen(str);
zend_string *cmd;
size_t estimate = (4 * l) + 3;

View file

@ -1098,7 +1098,7 @@ PHPAPI PHP_FUNCTION(fgetss)
php_stream *stream;
zend_string *allowed = NULL;
char *allowed_tags=NULL;
int allowed_tags_len=0;
size_t allowed_tags_len=0;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r|lS", &fd, &bytes, &allowed) == FAILURE) {
RETURN_FALSE;
@ -1196,8 +1196,8 @@ PHPAPI PHP_FUNCTION(fwrite)
zval *arg1;
char *arg2;
size_t arg2len;
int ret;
int num_bytes;
size_t ret;
size_t num_bytes;
zend_long arg3 = 0;
char *buffer = NULL;
php_stream *stream;
@ -1309,7 +1309,7 @@ PHPAPI PHP_FUNCTION(fseek)
PHP_STREAM_TO_ZVAL(stream, arg1);
RETURN_LONG(php_stream_seek(stream, arg2, whence));
RETURN_LONG(php_stream_seek(stream, arg2, (int)whence));
}
/* }}} */
@ -1355,7 +1355,7 @@ PHP_FUNCTION(mkdir)
context = php_stream_context_from_zval(zcontext, 0);
RETURN_BOOL(php_stream_mkdir(dir, mode, (recursive ? PHP_STREAM_MKDIR_RECURSIVE : 0) | REPORT_ERRORS, context));
RETURN_BOOL(php_stream_mkdir(dir, (int)mode, (recursive ? PHP_STREAM_MKDIR_RECURSIVE : 0) | REPORT_ERRORS, context));
}
/* }}} */
@ -1384,7 +1384,7 @@ PHP_FUNCTION(readfile)
{
char *filename;
size_t filename_len;
int size = 0;
size_t size = 0;
zend_bool use_include_path = 0;
zval *zcontext = NULL;
php_stream *stream;
@ -1427,7 +1427,7 @@ PHP_FUNCTION(umask)
if (ZEND_NUM_ARGS() == 0) {
umask(oldumask);
} else {
umask(arg1);
umask((int)arg1);
}
RETURN_LONG(oldumask);
@ -1439,7 +1439,7 @@ PHP_FUNCTION(umask)
PHPAPI PHP_FUNCTION(fpassthru)
{
zval *arg1;
int size;
size_t size;
php_stream *stream;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &arg1) == FAILURE) {
@ -1852,7 +1852,7 @@ PHP_FUNCTION(fputcsv)
char escape_char = '\\'; /* allow this to be set as parameter */
php_stream *stream;
zval *fp = NULL, *fields = NULL;
int ret;
size_t ret;
char *delimiter_str = NULL, *enclosure_str = NULL, *escape_str = NULL;
size_t delimiter_str_len = 0, enclosure_str_len = 0, escape_str_len = 0;
@ -1908,7 +1908,8 @@ PHP_FUNCTION(fputcsv)
/* {{{ PHPAPI size_t php_fputcsv(php_stream *stream, zval *fields, char delimiter, char enclosure, char escape_char TSRMLS_DC) */
PHPAPI size_t php_fputcsv(php_stream *stream, zval *fields, char delimiter, char enclosure, char escape_char TSRMLS_DC)
{
int count, i = 0, ret;
int count, i = 0;
size_t ret;
zval *field_tmp;
smart_str csvline = {0};
@ -2486,7 +2487,7 @@ PHP_FUNCTION(fnmatch)
RETURN_FALSE;
}
RETURN_BOOL( ! fnmatch( pattern, filename, flags ));
RETURN_BOOL( ! fnmatch( pattern, filename, (int)flags ));
}
/* }}} */
#endif

View file

@ -835,7 +835,7 @@ PHP_FUNCTION(clearstatcache)
return;
}
php_clear_stat_cache(clear_realpath_cache, filename, filename_len TSRMLS_CC);
php_clear_stat_cache(clear_realpath_cache, filename, (int)filename_len TSRMLS_CC);
}
/* }}} */

View file

@ -176,14 +176,14 @@ typedef struct _php_strip_tags_filter {
int persistent;
} php_strip_tags_filter;
static int php_strip_tags_filter_ctor(php_strip_tags_filter *inst, const char *allowed_tags, int allowed_tags_len, int persistent)
static int php_strip_tags_filter_ctor(php_strip_tags_filter *inst, const char *allowed_tags, size_t allowed_tags_len, int persistent)
{
if (allowed_tags != NULL) {
if (NULL == (inst->allowed_tags = pemalloc(allowed_tags_len, persistent))) {
return FAILURE;
}
memcpy((char *)inst->allowed_tags, allowed_tags, allowed_tags_len);
inst->allowed_tags_len = allowed_tags_len;
inst->allowed_tags_len = (int)allowed_tags_len;
} else {
inst->allowed_tags = NULL;
}
@ -861,7 +861,8 @@ static php_conv_err_t php_conv_qprint_encode_convert(php_conv_qprint_encode *ins
/* Check to see if this is EOL whitespace. */
if (inst->lbchars != NULL) {
unsigned char *ps2;
unsigned int j, lb_cnt2;
unsigned int lb_cnt2;
size_t j;
lb_cnt2 = 0;
ps2 = ps;
@ -1265,7 +1266,7 @@ static php_conv_err_t php_conv_get_ulong_prop_ex(const HashTable *ht, zend_ulong
zval tmp;
if (Z_TYPE_P(tmpval) != IS_LONG) {
ZVAL_DUP(&tmp, tmpval);;
ZVAL_DUP(&tmp, tmpval);
convert_to_long(&tmp);
tmpval = &tmp;
}
@ -1318,6 +1319,7 @@ static int php_conv_get_int_prop_ex(const HashTable *ht, int *pretval, char *fie
}
#endif
/* XXX this might need an additional fix so it uses size_t, whereby unsigned is quite big so leaving as is for now */
static int php_conv_get_uint_prop_ex(const HashTable *ht, unsigned int *pretval, char *field_name, size_t field_name_len)
{
zend_ulong l;
@ -1326,7 +1328,7 @@ static int php_conv_get_uint_prop_ex(const HashTable *ht, unsigned int *pretval,
*pretval = 0;
if ((err = php_conv_get_ulong_prop_ex(ht, &l, field_name, field_name_len)) == PHP_CONV_ERR_SUCCESS) {
*pretval = l;
*pretval = (unsigned int)l;
}
return err;
}
@ -1931,12 +1933,12 @@ typedef struct _php_chunked_filter_data {
int persistent;
} php_chunked_filter_data;
static int php_dechunk(char *buf, int len, php_chunked_filter_data *data)
static size_t php_dechunk(char *buf, size_t len, php_chunked_filter_data *data)
{
char *p = buf;
char *end = p + len;
char *out = buf;
int out_len = 0;
size_t out_len = 0;
while (p < end) {
switch (data->state) {

View file

@ -376,7 +376,7 @@ php_formatted_print(int param_count, int use_array, int format_offset TSRMLS_DC)
char *format, padding;
zend_string *result;
int always_sign;
int format_len;
size_t format_len;
if (zend_parse_parameters(param_count TSRMLS_CC, "+", &args, &argc) == FAILURE) {
return NULL;

View file

@ -35,14 +35,18 @@ static void php_fsockopen_stream(INTERNAL_FUNCTION_PARAMETERS, int persistent)
size_t host_len;
zend_long port = -1;
zval *zerrno = NULL, *zerrstr = NULL;
double timeout = FG(default_socket_timeout);
zend_ulong conv;
double timeout = (double)FG(default_socket_timeout);
#ifndef PHP_WIN32
time_t conv;
#else
long conv;
#endif
struct timeval tv;
char *hashkey = NULL;
php_stream *stream = NULL;
int err;
char *hostname = NULL;
zend_long hostname_len;
size_t hostname_len;
zend_string *errstr = NULL;
RETVAL_FALSE;
@ -63,8 +67,13 @@ static void php_fsockopen_stream(INTERNAL_FUNCTION_PARAMETERS, int persistent)
}
/* prepare the timeout value for use */
conv = (unsigned long) (timeout * 1000000.0);
#ifndef PHP_WIN32
conv = (time_t) (timeout * 1000000.0);
tv.tv_sec = conv / 1000000;
#else
conv = (long) (timeout * 1000000.0);
tv.tv_sec = conv / 1000000;
#endif
tv.tv_usec = conv % 1000000;
if (zerrno) {

View file

@ -155,7 +155,7 @@ static php_stream *php_ftp_fopen_connect(php_stream_wrapper *wrapper, const char
if (resource->port == 0)
resource->port = 21;
transport_len = spprintf(&transport, 0, "tcp://%s:%d", resource->host, resource->port);
transport_len = (int)spprintf(&transport, 0, "tcp://%s:%d", resource->host, resource->port);
stream = php_stream_xport_create(transport, transport_len, REPORT_ERRORS, STREAM_XPORT_CLIENT | STREAM_XPORT_CONNECT, NULL, NULL, context, NULL, NULL);
efree(transport);
if (stream == NULL) {
@ -245,7 +245,7 @@ static php_stream *php_ftp_fopen_connect(php_stream_wrapper *wrapper, const char
/* send the user name */
if (resource->user != NULL) {
tmp_len = php_raw_url_decode(resource->user, strlen(resource->user));
tmp_len = (int)php_raw_url_decode(resource->user, (int)strlen(resource->user));
PHP_FTP_CNTRL_CHK(resource->user, tmp_len, "Invalid login %s")
@ -262,7 +262,7 @@ static php_stream *php_ftp_fopen_connect(php_stream_wrapper *wrapper, const char
php_stream_notify_info(context, PHP_STREAM_NOTIFY_AUTH_REQUIRED, tmp_line, 0);
if (resource->pass != NULL) {
tmp_len = php_raw_url_decode(resource->pass, strlen(resource->pass));
tmp_len = (int)php_raw_url_decode(resource->pass, (int)strlen(resource->pass));
PHP_FTP_CNTRL_CHK(resource->pass, tmp_len, "Invalid password %s")
@ -424,8 +424,8 @@ php_stream * php_stream_url_wrap_ftp(php_stream_wrapper *wrapper, const char *pa
php_stream *reuseid=NULL;
size_t file_size = 0;
zval *tmpzval;
int allow_overwrite = 0;
int read_write = 0;
zend_bool allow_overwrite = 0;
int8_t read_write = 0;
char *transport;
int transport_len;
@ -498,7 +498,7 @@ php_stream * php_stream_url_wrap_ftp(php_stream_wrapper *wrapper, const char *pa
} else if (read_write == 2) {
/* when writing file (but not appending), it must NOT exist, unless a context option exists which allows it */
if (context && (tmpzval = php_stream_context_get_option(context, "ftp", "overwrite")) != NULL) {
allow_overwrite = Z_LVAL_P(tmpzval);
allow_overwrite = Z_LVAL_P(tmpzval) ? 1 : 0;
}
if (result <= 299 && result >= 200) {
if (allow_overwrite) {
@ -554,7 +554,7 @@ php_stream * php_stream_url_wrap_ftp(php_stream_wrapper *wrapper, const char *pa
if (hoststart == NULL) {
hoststart = resource->host;
}
transport_len = spprintf(&transport, 0, "tcp://%s:%d", hoststart, portno);
transport_len = (int)spprintf(&transport, 0, "tcp://%s:%d", hoststart, portno);
datastream = php_stream_xport_create(transport, transport_len, REPORT_ERRORS, STREAM_XPORT_CLIENT | STREAM_XPORT_CONNECT, NULL, NULL, context, NULL, NULL);
efree(transport);
if (datastream == NULL) {
@ -855,7 +855,7 @@ static int php_stream_ftp_url_stat(php_stream_wrapper *wrapper, const char *url,
gmt->tm_isdst = -1;
/* apply the GMT offset */
tm.tm_sec += stamp - mktime(gmt);
tm.tm_sec += (long)(stamp - mktime(gmt));
tm.tm_isdst = gmt->tm_isdst;
ssb->sb.st_mtime = mktime(&tm);

View file

@ -73,10 +73,10 @@ PHPAPI int php_header(TSRMLS_D)
}
PHPAPI int php_setcookie(char *name, int name_len, char *value, int value_len, time_t expires, char *path, int path_len, char *domain, int domain_len, int secure, int url_encode, int httponly TSRMLS_DC)
PHPAPI int php_setcookie(char *name, size_t name_len, char *value, size_t value_len, time_t expires, char *path, size_t path_len, char *domain, size_t domain_len, int secure, int url_encode, int httponly TSRMLS_DC)
{
char *cookie;
int len=sizeof("Set-Cookie: ");
size_t len=sizeof("Set-Cookie: ");
zend_string *dt;
sapi_header_line ctr = {0};
int result;
@ -164,7 +164,7 @@ PHPAPI int php_setcookie(char *name, int name_len, char *value, int value_len, t
}
ctr.line = cookie;
ctr.line_len = strlen(cookie);
ctr.line_len = (uint)strlen(cookie);
result = sapi_header_op(SAPI_HEADER_ADD, &ctr TSRMLS_CC);
efree(cookie);
@ -300,7 +300,7 @@ PHP_FUNCTION(http_response_code)
zend_long old_response_code;
old_response_code = SG(sapi_headers).http_response_code;
SG(sapi_headers).http_response_code = response_code;
SG(sapi_headers).http_response_code = (int)response_code;
if (old_response_code) {
RETURN_LONG(old_response_code);

View file

@ -38,6 +38,6 @@ PHP_FUNCTION(headers_list);
PHP_FUNCTION(http_response_code);
PHPAPI int php_header(TSRMLS_D);
PHPAPI int php_setcookie(char *name, int name_len, char *value, int value_len, time_t expires, char *path, int path_len, char *domain, int domain_len, int secure, int url_encode, int httponly TSRMLS_DC);
PHPAPI int php_setcookie(char *name, size_t name_len, char *value, size_t value_len, time_t expires, char *path, size_t path_len, char *domain, size_t domain_len, int secure, int url_encode, int httponly TSRMLS_DC);
#endif

View file

@ -377,7 +377,7 @@ static enum entity_charset determine_charset(char *charset_hint TSRMLS_DC)
{
int i;
enum entity_charset charset = cs_utf_8;
int len = 0;
size_t len = 0;
const zend_encoding *zenc;
/* Default is now UTF-8 */
@ -1513,7 +1513,7 @@ PHP_FUNCTION(htmlspecialchars_decode)
return;
}
replaced = php_unescape_html_entities((unsigned char*)str, str_len, 0 /*!all*/, quote_style, NULL TSRMLS_CC);
replaced = php_unescape_html_entities((unsigned char*)str, str_len, 0 /*!all*/, (int)quote_style, NULL TSRMLS_CC);
if (replaced) {
RETURN_STR(replaced);
}
@ -1547,7 +1547,7 @@ PHP_FUNCTION(html_entity_decode)
if (!hint_charset) {
default_charset = get_default_charset(TSRMLS_C);
}
replaced = php_unescape_html_entities((unsigned char*)str->val, str->len, 1 /*all*/, quote_style, (hint_charset ? hint_charset->val : default_charset) TSRMLS_CC);
replaced = php_unescape_html_entities((unsigned char*)str->val, str->len, 1 /*all*/, (int)quote_style, (hint_charset ? hint_charset->val : default_charset) TSRMLS_CC);
if (replaced) {
RETURN_STR(replaced);
@ -1649,7 +1649,7 @@ PHP_FUNCTION(get_html_translation_table)
array_init(return_value);
entity_table = determine_entity_table(all, doctype);
entity_table = determine_entity_table((int)all, doctype);
if (all && !CHARSET_UNICODE_COMPAT(charset)) {
to_uni_table = enc_to_uni_index[charset];
}

View file

@ -26,9 +26,9 @@
/* {{{ php_url_encode_hash */
PHPAPI int php_url_encode_hash_ex(HashTable *ht, smart_str *formstr,
const char *num_prefix, int num_prefix_len,
const char *key_prefix, int key_prefix_len,
const char *key_suffix, int key_suffix_len,
const char *num_prefix, size_t num_prefix_len,
const char *key_prefix, size_t key_prefix_len,
const char *key_suffix, size_t key_suffix_len,
zval *type, char *arg_sep, int enc_type TSRMLS_DC)
{
zend_string *key = NULL;
@ -107,7 +107,7 @@ PHPAPI int php_url_encode_hash_ex(HashTable *ht, smart_str *formstr,
*p = '\0';
} else {
char *ekey;
int ekey_len;
size_t ekey_len;
/* Is an integer key */
ekey_len = spprintf(&ekey, 0, "%pd", idx);
newprefix_len = key_prefix_len + num_prefix_len + ekey_len + key_suffix_len + 3 /* %5B */;
@ -194,7 +194,7 @@ PHPAPI int php_url_encode_hash_ex(HashTable *ht, smart_str *formstr,
case IS_DOUBLE:
{
char *ekey;
int ekey_len;
size_t ekey_len;
ekey_len = spprintf(&ekey, 0, "%.*G", (int) EG(precision), Z_DVAL_P(zdata));
smart_str_appendl(formstr, ekey, ekey_len);
efree(ekey);
@ -242,7 +242,7 @@ PHP_FUNCTION(http_build_query)
RETURN_FALSE;
}
if (php_url_encode_hash_ex(HASH_OF(formdata), &formstr, prefix, prefix_len, NULL, 0, NULL, 0, (Z_TYPE_P(formdata) == IS_OBJECT ? formdata : NULL), arg_sep, enc_type TSRMLS_CC) == FAILURE) {
if (php_url_encode_hash_ex(HASH_OF(formdata), &formstr, prefix, prefix_len, NULL, 0, NULL, 0, (Z_TYPE_P(formdata) == IS_OBJECT ? formdata : NULL), arg_sep, (int)enc_type TSRMLS_CC) == FAILURE) {
if (formstr.s) {
smart_str_free(&formstr);
}

View file

@ -121,7 +121,7 @@ php_stream *php_stream_url_wrap_http_ex(php_stream_wrapper *wrapper,
char *tmp = NULL;
char *ua_str = NULL;
zval *ua_zval = NULL, *tmpzval = NULL, ssl_proxy_peer_name;
int scratch_len = 0;
size_t scratch_len = 0;
int body = 0;
char location[HTTP_HEADER_BLOCK_SIZE];
zval *response_header = NULL;
@ -132,14 +132,16 @@ php_stream *php_stream_url_wrap_http_ex(php_stream_wrapper *wrapper,
int eol_detect = 0;
char *transport_string;
zend_string *errstr = NULL;
int transport_len, have_header = 0, request_fulluri = 0, ignore_errors = 0;
size_t transport_len;
int have_header = 0;
zend_bool request_fulluri = 0, ignore_errors = 0;
char *protocol_version = NULL;
int protocol_version_len = 3; /* Default: "1.0" */
struct timeval timeout;
char *user_headers = NULL;
int header_init = ((flags & HTTP_WRAPPER_HEADER_INIT) != 0);
int redirected = ((flags & HTTP_WRAPPER_REDIRECTED) != 0);
int follow_location = 1;
zend_bool follow_location = 1;
php_stream_filter *transfer_encoding = NULL;
int response_code;
zend_array *symbol_table;
@ -201,10 +203,19 @@ php_stream *php_stream_url_wrap_http_ex(php_stream_wrapper *wrapper,
if (context && (tmpzval = php_stream_context_get_option(context, wrapper->wops->label, "timeout")) != NULL) {
double d = zval_get_double(tmpzval);
#ifndef PHP_WIN32
timeout.tv_sec = (time_t) d;
timeout.tv_usec = (size_t) ((d - timeout.tv_sec) * 1000000);
#else
timeout.tv_sec = (long) d;
timeout.tv_usec = (long) ((d - timeout.tv_sec) * 1000000);
#endif
} else {
#ifndef PHP_WIN32
timeout.tv_sec = FG(default_socket_timeout);
#else
timeout.tv_sec = (long)FG(default_socket_timeout);
#endif
timeout.tv_usec = 0;
}
@ -346,7 +357,7 @@ finish:
php_stream_notify_info(context, PHP_STREAM_NOTIFY_CONNECT, NULL, 0);
if (header_init && context && (tmpzval = php_stream_context_get_option(context, "http", "max_redirects")) != NULL) {
redirect_max = zval_get_long(tmpzval);
redirect_max = (int)zval_get_long(tmpzval);
}
if (context && (tmpzval = php_stream_context_get_option(context, "http", "method")) != NULL) {
@ -366,7 +377,7 @@ finish:
}
if (context && (tmpzval = php_stream_context_get_option(context, "http", "protocol_version")) != NULL) {
protocol_version_len = spprintf(&protocol_version, 0, "%.1F", zval_get_double(tmpzval));
protocol_version_len = (int)spprintf(&protocol_version, 0, "%.1F", zval_get_double(tmpzval));
}
if (!scratch) {
@ -378,7 +389,7 @@ finish:
/* Should we send the entire path in the request line, default to no. */
if (!request_fulluri && context &&
(tmpzval = php_stream_context_get_option(context, "http", "request_fulluri")) != NULL) {
request_fulluri = zend_is_true(tmpzval TSRMLS_CC) ? 1 : 0;
request_fulluri = zend_is_true(tmpzval TSRMLS_CC);
}
if (request_fulluri) {
@ -731,7 +742,7 @@ finish:
if (!strncasecmp(http_header_line, "Location: ", 10)) {
if (context && (tmpzval = php_stream_context_get_option(context, "http", "follow_location")) != NULL) {
follow_location = zval_get_long(tmpzval);
follow_location = zval_is_true(tmpzval);
} else if (!(response_code >= 300 && response_code < 304 || 307 == response_code || 308 == response_code)) {
/* we shouldn't redirect automatically
if follow_location isn't set and response_code not in (300, 301, 302, 303 and 307)
@ -843,7 +854,7 @@ finish:
#define CHECK_FOR_CNTRL_CHARS(val) { \
if (val) { \
unsigned char *s, *e; \
int l; \
size_t l; \
l = php_url_decode(val, strlen(val)); \
s = (unsigned char*)val; e = s + l; \
while (s < e) { \
@ -891,7 +902,7 @@ out:
/* Restore original chunk size now that we're done with headers */
if (options & STREAM_WILL_CAST)
php_stream_set_chunk_size(stream, chunk_size);
php_stream_set_chunk_size(stream, (int)chunk_size);
/* restore the users auto-detect-line-endings setting */
stream->flags |= eol_detect;

View file

@ -61,9 +61,9 @@ PHPAPI extern char *php_ini_opened_path;
PHPAPI extern char *php_ini_scanned_path;
PHPAPI extern char *php_ini_scanned_files;
static int php_info_print_html_esc(const char *str, int len) /* {{{ */
static int php_info_print_html_esc(const char *str, size_t len) /* {{{ */
{
int written;
size_t written;
zend_string *new_str;
TSRMLS_FETCH();
@ -77,7 +77,7 @@ static int php_info_print_html_esc(const char *str, int len) /* {{{ */
static int php_info_printf(const char *fmt, ...) /* {{{ */
{
char *buf;
int len, written;
size_t len, written;
va_list argv;
TSRMLS_FETCH();
@ -1026,7 +1026,7 @@ PHPAPI void php_info_print_table_colspan_header(int num_cols, char *header) /* {
if (!sapi_module.phpinfo_as_text) {
php_info_printf("<tr class=\"h\"><th colspan=\"%d\">%s</th></tr>\n", num_cols, header );
} else {
spaces = (74 - strlen(header));
spaces = (int)(74 - strlen(header));
php_info_printf("%*s%s%*s\n", (int)(spaces/2), " ", header, (int)(spaces/2), " ");
}
}
@ -1176,7 +1176,7 @@ PHP_FUNCTION(phpinfo)
/* Andale! Andale! Yee-Hah! */
php_output_start_default(TSRMLS_C);
php_print_info(flag TSRMLS_CC);
php_print_info((int)flag TSRMLS_CC);
php_output_end(TSRMLS_C);
RETURN_TRUE;
@ -1218,7 +1218,7 @@ PHP_FUNCTION(phpcredits)
return;
}
php_print_credits(flag TSRMLS_CC);
php_print_credits((int)flag TSRMLS_CC);
RETURN_TRUE;
}
/* }}} */

View file

@ -27,10 +27,11 @@
/* {{{ reference_levdist
* reference implementation, only optimized for memory usage, not speed */
static int reference_levdist(const char *s1, int l1, const char *s2, int l2, int cost_ins, int cost_rep, int cost_del )
static zend_long reference_levdist(const char *s1, size_t l1, const char *s2, size_t l2, zend_long cost_ins, zend_long cost_rep, zend_long cost_del )
{
int *p1, *p2, *tmp;
int i1, i2, c0, c1, c2;
zend_long *p1, *p2, *tmp;
zend_long c0, c1, c2;
size_t i1, i2;
if (l1 == 0) {
return l2 * cost_ins;
@ -42,8 +43,8 @@ static int reference_levdist(const char *s1, int l1, const char *s2, int l2, int
if ((l1 > LEVENSHTEIN_MAX_LENGTH) || (l2 > LEVENSHTEIN_MAX_LENGTH)) {
return -1;
}
p1 = safe_emalloc((l2 + 1), sizeof(int), 0);
p2 = safe_emalloc((l2 + 1), sizeof(int), 0);
p1 = safe_emalloc((l2 + 1), sizeof(zend_long), 0);
p2 = safe_emalloc((l2 + 1), sizeof(zend_long), 0);
for (i2 = 0; i2 <= l2; i2++) {
p1[i2] = i2 * cost_ins;
@ -96,7 +97,7 @@ PHP_FUNCTION(levenshtein)
char *callback_name;
size_t str1_len, str2_len, callback_len;
zend_long cost_ins, cost_rep, cost_del;
int distance = -1;
zend_long distance = -1;
switch (argc) {
case 2: /* just two strings: use maximum performance version */

View file

@ -251,7 +251,7 @@ PHPAPI int php_mail(char *to, char *subject, char *message, char *headers, char
if (mail_log && *mail_log) {
char *tmp;
time_t curtime;
int l;
size_t l;
zend_string *date_str;
time(&curtime);

View file

@ -382,7 +382,7 @@ PHP_FUNCTION(round)
case IS_DOUBLE:
return_val = (Z_TYPE_P(value) == IS_LONG) ? (double)Z_LVAL_P(value) : Z_DVAL_P(value);
return_val = _php_math_round(return_val, places, mode);
return_val = _php_math_round(return_val, (int)places, (int)mode);
RETURN_DOUBLE(return_val);
break;
@ -946,7 +946,7 @@ PHP_FUNCTION(rad2deg)
PHPAPI zend_long _php_math_basetolong(zval *arg, int base)
{
zend_long num = 0, digit, onum;
int i;
zend_long i;
char c, *s;
if (Z_TYPE_P(arg) != IS_STRING || base < 2 || base > 36) {
@ -992,7 +992,7 @@ PHPAPI int _php_math_basetozval(zval *arg, int base, zval *ret)
{
zend_long num = 0;
double fnum = 0;
int i;
zend_long i;
int mode = 0;
char c, *s;
zend_long cutoff;
@ -1029,7 +1029,7 @@ PHPAPI int _php_math_basetozval(zval *arg, int base, zval *ret)
num = num * base + c;
break;
} else {
fnum = num;
fnum = (double)num;
mode = 1;
}
/* fall-through */
@ -1234,10 +1234,10 @@ PHP_FUNCTION(base_convert)
RETURN_FALSE;
}
if(_php_math_basetozval(number, frombase, &temp) == FAILURE) {
if(_php_math_basetozval(number, (int)frombase, &temp) == FAILURE) {
RETURN_FALSE;
}
result = _php_math_zvaltobase(&temp, tobase TSRMLS_CC);
result = _php_math_zvaltobase(&temp, (int)tobase TSRMLS_CC);
RETVAL_STR(result);
}
/* }}} */
@ -1284,15 +1284,15 @@ PHPAPI zend_string *_php_math_number_format_ex(double d, int dec, char *dec_poin
/* calculate the length of the return buffer */
if (dp) {
integral = dp - tmpbuf->val;
integral = (int)(dp - tmpbuf->val);
} else {
/* no decimal point was found */
integral = tmpbuf->len;
integral = (int)tmpbuf->len;
}
/* allow for thousand separators */
if (thousand_sep) {
integral += thousand_sep_len * ((integral-1) / 3);
integral += (int)(thousand_sep_len * ((integral-1) / 3));
}
reslen = integral;
@ -1301,7 +1301,7 @@ PHPAPI zend_string *_php_math_number_format_ex(double d, int dec, char *dec_poin
reslen += dec;
if (dec_point) {
reslen += dec_point_len;
reslen += (int)dec_point_len;
}
}
@ -1319,7 +1319,7 @@ PHPAPI zend_string *_php_math_number_format_ex(double d, int dec, char *dec_poin
* Take care, as the sprintf implementation may return less places than
* we requested due to internal buffer limitations */
if (dec) {
int declen = dp ? s - dp : 0;
int declen = (int)(dp ? s - dp : 0);
int topad = dec > declen ? dec - declen : 0;
/* pad with '0's */
@ -1391,7 +1391,7 @@ PHP_FUNCTION(number_format)
RETURN_STR(_php_math_number_format(num, 0, dec_point_chr, thousand_sep_chr));
break;
case 2:
RETURN_STR(_php_math_number_format(num, dec, dec_point_chr, thousand_sep_chr));
RETURN_STR(_php_math_number_format(num, (int)dec, dec_point_chr, thousand_sep_chr));
break;
case 4:
if (dec_point == NULL) {
@ -1404,7 +1404,7 @@ PHP_FUNCTION(number_format)
thousand_sep_len = 1;
}
RETVAL_STR(_php_math_number_format_ex(num, dec,
RETVAL_STR(_php_math_number_format_ex(num, (int)dec,
dec_point, dec_point_len, thousand_sep, thousand_sep_len));
break;
default:

View file

@ -912,7 +912,7 @@ PHP_FUNCTION(unpack)
case 'P': {
int issigned = 0;
int *map = machine_endian_longlong_map;
long v = 0;
zend_long v = 0;
if (type == 'q' || type == 'Q') {
issigned = input[inputpos + (machine_little_endian ? 7 : 0)] & 0x80;
@ -927,9 +927,9 @@ PHP_FUNCTION(unpack)
v = php_unpack(&input[inputpos], 8, issigned, map);
if (type == 'q') {
v = (signed long int) v;
v = (zend_long) v;
} else {
v = (unsigned long int) v;
v = (zend_ulong) v;
}
add_assoc_long(return_value, n, v);

View file

@ -268,7 +268,7 @@ PHP_FUNCTION(password_verify)
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss", &password, &password_len, &hash, &hash_len) == FAILURE) {
RETURN_FALSE;
}
if ((ret = php_crypt(password, password_len, hash, hash_len)) == NULL) {
if ((ret = php_crypt(password, (int)password_len, hash, (int)hash_len)) == NULL) {
RETURN_FALSE;
}
@ -298,7 +298,8 @@ PHP_FUNCTION(password_hash)
{
char *hash_format, *hash, *salt, *password;
zend_long algo = 0;
size_t password_len = 0, hash_len;
size_t password_len = 0;
int hash_len;
size_t salt_len = 0, required_salt_len = 0, hash_format_len;
HashTable *options = 0;
zval *option_buffer;
@ -344,7 +345,7 @@ PHP_FUNCTION(password_hash)
if (options && (option_buffer = zend_symtable_str_find(options, "salt", sizeof("salt")-1)) != NULL) {
char *buffer;
int buffer_len_int = 0;
size_t buffer_len_int = 0;
size_t buffer_len;
switch (Z_TYPE_P(option_buffer)) {
case IS_STRING:
@ -425,7 +426,7 @@ PHP_FUNCTION(password_hash)
/* This cast is safe, since both values are defined here in code and cannot overflow */
hash_len = (int) (hash_format_len + salt_len);
if ((result = php_crypt(password, password_len, hash, hash_len)) == NULL) {
if ((result = php_crypt(password, (int)password_len, hash, hash_len)) == NULL) {
efree(hash);
RETURN_FALSE;
}

View file

@ -80,7 +80,7 @@ static size_t php_stream_input_read(php_stream *stream, char *buf, size_t count
php_stream_input_t *input = stream->abstract;
size_t read;
if (!SG(post_read) && SG(read_post_bytes) < input->position + count) {
if (!SG(post_read) && SG(read_post_bytes) < (int64_t)(input->position + count)) {
/* read requested data from SAPI */
int read_bytes = sapi_read_post_block(buf, count TSRMLS_CC);
@ -323,7 +323,7 @@ php_stream * php_stream_url_wrap_php(php_stream_wrapper *wrapper, const char *pa
return NULL;
}
fd = dup(fildes_ori);
fd = dup((int)fildes_ori);
if (fd == -1) {
php_stream_wrapper_log_error(wrapper, options TSRMLS_CC,
"Error duping file descriptor " ZEND_LONG_FMT "; possibly it doesn't exist: "

View file

@ -25,9 +25,9 @@
#include "zend_smart_str.h"
PHPAPI int php_url_encode_hash_ex(HashTable *ht, smart_str *formstr,
const char *num_prefix, int num_prefix_len,
const char *key_prefix, int key_prefix_len,
const char *key_suffix, int key_suffix_len,
const char *num_prefix, size_t num_prefix_len,
const char *key_prefix, size_t key_prefix_len,
const char *key_suffix, size_t key_suffix_len,
zval *type, char *arg_sep, int enc_type TSRMLS_DC);
#define php_url_encode_hash(ht, formstr) php_url_encode_hash_ex((ht), (formstr), NULL, 0, NULL, 0, NULL, 0, NULL TSRMLS_CC)

View file

@ -82,7 +82,7 @@ static php_process_env_t _php_array_to_envp(zval *environment, int is_persistent
char **ep;
#endif
char *p;
uint cnt, l, sizeenv=0;
size_t cnt, l, sizeenv=0;
HashTable *target_hash;
memset(&env, 0, sizeof(env));
@ -109,7 +109,7 @@ static php_process_env_t _php_array_to_envp(zval *environment, int is_persistent
/* first, we have to get the size of all the elements in the hash */
ZEND_HASH_FOREACH_STR_KEY_VAL(target_hash, string_key, element) {
zend_string *str = zval_get_string(element);
uint el_len = str->len;
size_t el_len = str->len;
zend_string_release(str);
if (el_len == 0) {
@ -512,7 +512,7 @@ PHP_FUNCTION(proc_open)
goto exit_fail;
}
descriptors[ndesc].index = nindex;
descriptors[ndesc].index = (int)nindex;
if (Z_TYPE_P(descitem) == IS_RESOURCE) {
/* should be a stream - try and dup the descriptor */
@ -526,7 +526,7 @@ PHP_FUNCTION(proc_open)
}
#ifdef PHP_WIN32
descriptors[ndesc].childend = dup_fd_as_handle(fd);
descriptors[ndesc].childend = dup_fd_as_handle((int)fd);
if (descriptors[ndesc].childend == NULL) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "unable to dup File-Handle for descriptor %d", nindex);
goto exit_fail;
@ -621,8 +621,8 @@ PHP_FUNCTION(proc_open)
}
#ifdef PHP_WIN32
descriptors[ndesc].childend = dup_fd_as_handle(fd);
_close(fd);
descriptors[ndesc].childend = dup_fd_as_handle((int)fd);
_close((int)fd);
/* simulate the append mode by fseeking to the end of the file
this introduces a potential race-condition, but it is the best we can do, though */

View file

@ -53,7 +53,7 @@ static char php_hex2int(int c) /* {{{ */
PHPAPI zend_string *php_quot_print_decode(const unsigned char *str, size_t length, int replace_us_by_ws) /* {{{ */
{
register unsigned int i;
register size_t i;
register unsigned const char *p1;
register unsigned char *p2;
register unsigned int h_nbl, l_nbl;

View file

@ -78,7 +78,7 @@ PHP_FUNCTION(soundex)
if (code >= 'A' && code <= 'Z') {
if (_small == 0) {
/* remember first valid char */
soundex[_small++] = code;
soundex[_small++] = (char)code;
last = soundex_table[code - 'A'];
}
else {
@ -88,7 +88,7 @@ PHP_FUNCTION(soundex)
code = soundex_table[code - 'A'];
if (code != last) {
if (code != 0) {
soundex[_small++] = code;
soundex[_small++] = (char)code;
}
last = code;
}

View file

@ -60,7 +60,7 @@ PHP_FUNCTION(stream_socket_pair)
RETURN_FALSE;
}
if (0 != socketpair(domain, type, protocol, pair)) {
if (0 != socketpair((int)domain, (int)type, (int)protocol, pair)) {
char errbuf[256];
php_error_docref(NULL TSRMLS_CC, E_WARNING, "failed to create sockets: [%d]: %s",
php_socket_errno(), php_socket_strerror(php_socket_errno(), errbuf, sizeof(errbuf)));
@ -90,7 +90,7 @@ PHP_FUNCTION(stream_socket_client)
char *host;
size_t host_len;
zval *zerrno = NULL, *zerrstr = NULL, *zcontext = NULL;
double timeout = FG(default_socket_timeout);
double timeout = (double)FG(default_socket_timeout);
php_timeout_ull conv;
struct timeval tv;
char *hashkey = NULL;
@ -206,7 +206,7 @@ PHP_FUNCTION(stream_socket_server)
}
stream = php_stream_xport_create(host, host_len, REPORT_ERRORS,
STREAM_XPORT_SERVER | flags,
STREAM_XPORT_SERVER | (int)flags,
NULL, NULL, context, &errstr, &err);
if (stream == NULL) {
@ -239,7 +239,7 @@ PHP_FUNCTION(stream_socket_server)
Accept a client connection from a server socket */
PHP_FUNCTION(stream_socket_accept)
{
double timeout = FG(default_socket_timeout);
double timeout = (double)FG(default_socket_timeout);
zval *zpeername = NULL;
zend_string *peername = NULL;
php_timeout_ull conv;
@ -340,7 +340,7 @@ PHP_FUNCTION(stream_socket_sendto)
}
}
RETURN_LONG(php_stream_xport_sendto(stream, data, datalen, flags, target_addr ? &sa : NULL, sl TSRMLS_CC));
RETURN_LONG(php_stream_xport_sendto(stream, data, datalen, (int)flags, target_addr ? &sa : NULL, sl TSRMLS_CC));
}
/* }}} */
@ -374,7 +374,7 @@ PHP_FUNCTION(stream_socket_recvfrom)
read_buf = zend_string_alloc(to_read, 0);
recvd = php_stream_xport_recvfrom(stream, read_buf->val, to_read, flags, NULL, NULL,
recvd = php_stream_xport_recvfrom(stream, read_buf->val, to_read, (int)flags, NULL, NULL,
zremote ? &remote_addr : NULL
TSRMLS_CC);
@ -410,7 +410,7 @@ PHP_FUNCTION(stream_get_contents)
if (desiredpos >= 0) {
int seek_res = 0;
off_t position;
zend_off_t position;
position = php_stream_tell(stream);
if (position >= 0 && desiredpos > position) {
@ -773,6 +773,10 @@ PHP_FUNCTION(stream_select)
RETURN_FALSE;
}
#ifdef PHP_WIN32
tv.tv_sec = (long)(Z_LVAL_P(sec) + (usec / 1000000));
tv.tv_usec = (long)(usec % 1000000);
#else
/* Solaris + BSD do not like microsecond values which are >= 1 sec */
if (usec > 999999) {
tv.tv_sec = Z_LVAL_P(sec) + (usec / 1000000);
@ -781,7 +785,7 @@ PHP_FUNCTION(stream_select)
tv.tv_sec = Z_LVAL_P(sec);
tv.tv_usec = usec;
}
#endif
tv_p = &tv;
}
@ -1275,19 +1279,16 @@ PHP_FUNCTION(stream_get_line)
PHP_FUNCTION(stream_set_blocking)
{
zval *arg1;
int block;
zend_long arg2;
zend_long block;
php_stream *stream;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rl", &arg1, &arg2) == FAILURE) {
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rl", &arg1, &block) == FAILURE) {
return;
}
php_stream_from_zval(stream, arg1);
block = arg2;
if (php_stream_set_option(stream, PHP_STREAM_OPTION_BLOCKING, block == 0 ? 0 : 1, NULL) == -1) {
if (php_stream_set_option(stream, PHP_STREAM_OPTION_BLOCKING, block ? 1 : 0, NULL) == -1) {
RETURN_FALSE;
}
@ -1313,6 +1314,16 @@ PHP_FUNCTION(stream_set_timeout)
php_stream_from_zval(stream, socket);
#ifdef PHP_WIN32
t.tv_sec = (long)seconds;
if (argc == 3) {
t.tv_usec = (long)(microseconds % 1000000);
t.tv_sec +=(long)(microseconds / 1000000);
} else {
t.tv_usec = 0;
}
#else
t.tv_sec = seconds;
if (argc == 3) {
@ -1321,6 +1332,7 @@ PHP_FUNCTION(stream_set_timeout)
} else {
t.tv_usec = 0;
}
#endif
if (PHP_STREAM_OPTION_RETURN_OK == php_stream_set_option(stream, PHP_STREAM_OPTION_READ_TIMEOUT, 0, &t)) {
RETURN_TRUE;
@ -1485,7 +1497,7 @@ PHP_FUNCTION(stream_resolve_include_path)
return;
}
resolved_path = zend_resolve_path(filename, filename_len TSRMLS_CC);
resolved_path = zend_resolve_path(filename, (int)filename_len TSRMLS_CC);
if (resolved_path) {
// TODO: avoid reallocation ???

View file

@ -1663,12 +1663,10 @@ static int php_needle_char(zval *needle, char *target TSRMLS_DC)
return SUCCESS;
case IS_OBJECT:
{
zval holder = *needle;
zval_copy_ctor(&(holder));
convert_to_long(&(holder));
if(Z_TYPE(holder) != IS_LONG) {
return FAILURE;
}
zval holder;
ZVAL_LONG(&holder, zval_get_long(needle));
*target = (char)Z_LVAL(holder);
return SUCCESS;
}
@ -2766,20 +2764,20 @@ PHP_FUNCTION(ucwords)
PHPAPI char *php_strtr(char *str, size_t len, char *str_from, char *str_to, size_t trlen)
{
size_t i;
unsigned char xlat[256];
unsigned char xlat[256], j;
if ((trlen < 1) || (len < 1)) {
return str;
}
for (i = 0; i < 256; xlat[i] = i, i++);
for (j = 0; j < 256; xlat[j] = j, j++);
for (i = 0; i < trlen; i++) {
xlat[(unsigned char) str_from[i]] = str_to[i];
xlat[(size_t) str_from[i]] = str_to[i];
}
for (i = 0; i < len; i++) {
str[i] = xlat[(unsigned char) str[i]];
str[i] = xlat[(size_t) str[i]];
}
return str;
@ -4185,7 +4183,7 @@ PHP_FUNCTION(setlocale)
#ifdef HAVE_SETLOCALE
if (Z_TYPE_P(pcategory) == IS_LONG) {
cat = Z_LVAL_P(pcategory);
cat = (int)Z_LVAL_P(pcategory);
} else {
/* FIXME: The following behaviour should be removed. */
char *category;
@ -4896,14 +4894,14 @@ PHP_FUNCTION(localeconv)
localeconv_r( &currlocdata );
/* Grab the grouping data out of the array */
len = strlen(currlocdata.grouping);
len = (int)strlen(currlocdata.grouping);
for (i = 0; i < len; i++) {
add_index_long(&grouping, i, currlocdata.grouping[i]);
}
/* Grab the monetary grouping data out of the array */
len = strlen(currlocdata.mon_grouping);
len = (int)strlen(currlocdata.mon_grouping);
for (i = 0; i < len; i++) {
add_index_long(&mon_grouping, i, currlocdata.mon_grouping[i]);
@ -5346,7 +5344,7 @@ PHP_FUNCTION(str_split)
return;
}
array_init_size(return_value, ((str->len - 1) / split_length) + 1);
array_init_size(return_value, (uint32_t)(((str->len - 1) / split_length) + 1));
n_reg_segments = str->len / split_length;
p = str->val;

View file

@ -6,7 +6,7 @@ Bug #68044 Integer overflow in unserialize() (32-bits only)
?>
===DONE==
--EXPECTF--
Warning: Insufficient data for unserializing - %d required, 1 present in %s/bug68044.php on line 2
Warning: Insufficient data for unserializing - %d required, 1 present in %s%ebug68044.php on line 2
Notice: unserialize(): Error at offset 32 of 33 bytes in %s/bug68044.php on line 2
Notice: unserialize(): Error at offset 32 of 33 bytes in %s%ebug68044.php on line 2
===DONE==

View file

@ -156,7 +156,7 @@ PHP_FUNCTION(intval)
#endif
RETVAL_ZVAL(num, 1, 0);
convert_to_long_base(return_value, base);
convert_to_long_base(return_value, (int)base);
}
/* }}} */

View file

@ -61,7 +61,7 @@ PHPAPI void php_url_free(php_url *theurl)
/* {{{ php_replace_controlchars
*/
PHPAPI char *php_replace_controlchars_ex(char *str, int len)
PHPAPI char *php_replace_controlchars_ex(char *str, size_t len)
{
unsigned char *s = (unsigned char *)str;
unsigned char *e = (unsigned char *)str + len;
@ -94,7 +94,7 @@ PHPAPI php_url *php_url_parse(char const *str)
/* {{{ php_url_parse
*/
PHPAPI php_url *php_url_parse_ex(char const *str, int length)
PHPAPI php_url *php_url_parse_ex(char const *str, size_t length)
{
char port_buf[6];
php_url *ret = ecalloc(1, sizeof(php_url));
@ -481,7 +481,7 @@ static unsigned char hexchars[] = "0123456789ABCDEF";
/* {{{ php_url_encode
*/
PHPAPI zend_string *php_url_encode(char const *s, int len)
PHPAPI zend_string *php_url_encode(char const *s, size_t len)
{
register unsigned char c;
unsigned char *to;
@ -572,7 +572,7 @@ PHP_FUNCTION(urldecode)
/* {{{ php_url_decode
*/
PHPAPI int php_url_decode(char *str, int len)
PHPAPI size_t php_url_decode(char *str, size_t len)
{
char *dest = str;
char *data = str;
@ -603,7 +603,7 @@ PHPAPI int php_url_decode(char *str, int len)
/* {{{ php_raw_url_encode
*/
PHPAPI zend_string *php_raw_url_encode(char const *s, int len)
PHPAPI zend_string *php_raw_url_encode(char const *s, size_t len)
{
register int x, y;
zend_string *str;
@ -679,7 +679,7 @@ PHP_FUNCTION(rawurldecode)
/* {{{ php_raw_url_decode
*/
PHPAPI int php_raw_url_decode(char *str, int len)
PHPAPI size_t php_raw_url_decode(char *str, size_t len)
{
char *dest = str;
char *data = str;

View file

@ -33,11 +33,12 @@ typedef struct php_url {
PHPAPI void php_url_free(php_url *theurl);
PHPAPI php_url *php_url_parse(char const *str);
PHPAPI php_url *php_url_parse_ex(char const *str, int length);
PHPAPI int php_url_decode(char *str, int len); /* return value: length of decoded string */
PHPAPI int php_raw_url_decode(char *str, int len); /* return value: length of decoded string */
PHPAPI zend_string *php_url_encode(char const *s, int len);
PHPAPI zend_string *php_raw_url_encode(char const *s, int len);
PHPAPI php_url *php_url_parse_ex(char const *str, size_t length);
PHPAPI size_t php_url_decode(char *str, size_t len); /* return value: length of decoded string */
PHPAPI size_t php_raw_url_decode(char *str, size_t len); /* return value: length of decoded string */
PHPAPI zend_string *php_url_encode(char const *s, size_t len);
PHPAPI zend_string *php_raw_url_encode(char const *s, size_t len);
PHPAPI char *php_replace_controlchars_ex(char *str, size_t len);
PHP_FUNCTION(parse_url);
PHP_FUNCTION(urlencode);

View file

@ -83,7 +83,7 @@ PHPAPI zend_string *php_uuencode(char *src, size_t src_len) /* {{{ */
ee = e;
len = ee - s;
if (len % 3) {
ee = s + (int) (floor(len / 3) * 3);
ee = s + (int) (floor((double)len / 3) * 3);
}
}
*p++ = PHP_UU_ENC(len);
@ -173,7 +173,8 @@ PHPAPI zend_string *php_uudecode(char *src, size_t src_len) /* {{{ */
s++;
}
if ((len = total_len > (p - dest->val))) {
assert(p >= dest->val);
if ((len = total_len > (size_t)(p - dest->val))) {
*p++ = PHP_UU_DEC(*s) << 2 | PHP_UU_DEC(*(s + 1)) >> 4;
if (len > 1) {
*p++ = PHP_UU_DEC(*(s + 1)) << 4 | PHP_UU_DEC(*(s + 2)) >> 2;

View file

@ -389,7 +389,7 @@ PHP_FUNCTION(debug_zval_dump)
#define buffer_append_spaces(buf, num_spaces) \
do { \
char *tmp_spaces; \
int tmp_spaces_len; \
size_t tmp_spaces_len; \
tmp_spaces_len = spprintf(&tmp_spaces, 0,"%*c", num_spaces, ' '); \
smart_str_appendl(buf, tmp_spaces, tmp_spaces_len); \
efree(tmp_spaces); \
@ -594,7 +594,7 @@ PHP_FUNCTION(var_export)
static void php_var_serialize_intern(smart_str *buf, zval *struc, php_serialize_data_t var_hash TSRMLS_DC);
static inline uint32_t php_add_var_hash(php_serialize_data_t data, zval *var TSRMLS_DC) /* {{{ */
static inline zend_long php_add_var_hash(php_serialize_data_t data, zval *var TSRMLS_DC) /* {{{ */
{
zval *zv;
zend_ulong key;
@ -772,7 +772,7 @@ static void php_var_serialize_class(smart_str *buf, zval *struc, zval *retval_pt
static void php_var_serialize_intern(smart_str *buf, zval *struc, php_serialize_data_t var_hash TSRMLS_DC) /* {{{ */
{
uint32_t var_already;
zend_long var_already;
HashTable *myht;
if (EG(exception)) {
@ -816,7 +816,7 @@ again:
smart_str_appendl(buf, "d:", 2);
s = (char *) safe_emalloc(PG(serialize_precision), 1, MAX_LENGTH_OF_DOUBLE + 1);
php_gcvt(Z_DVAL_P(struc), PG(serialize_precision), '.', 'E', s);
php_gcvt(Z_DVAL_P(struc), (int)PG(serialize_precision), '.', 'E', s);
smart_str_appends(buf, s);
smart_str_appendc(buf, ';');
efree(s);

View file

@ -497,7 +497,9 @@ static void TIDY_CALL php_tidy_panic(ctmbstr msg)
static int _php_tidy_set_tidy_opt(TidyDoc doc, char *optname, zval *value TSRMLS_DC)
{
TidyOption opt = tidyGetOptionByName(doc, optname);
zval conv = *value;
zval conv;
ZVAL_COPY_VALUE(&conv, value);
if (!opt) {
php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Unknown Tidy Configuration Option '%s'", optname);

View file

@ -311,7 +311,7 @@ PHPAPI char *php_gcvt(double value, int ndigit, char dec_point, char exponent, c
* is declared as buf[ 100 ], buf_end should be &buf[ 100 ])
*/
/* char * ap_php_conv_10() {{{ */
char * ap_php_conv_10(register wide_int num, register bool_int is_unsigned,
PHPAPI char * ap_php_conv_10(register wide_int num, register bool_int is_unsigned,
register bool_int * is_negative, char *buf_end, register size_t *len)
{
register char *p = buf_end;
@ -474,7 +474,7 @@ PHPAPI char * php_conv_fp(register char format, register double num,
* which is a pointer to the END of the buffer + 1 (i.e. if the buffer
* is declared as buf[ 100 ], buf_end should be &buf[ 100 ])
*/
char * ap_php_conv_p2(register u_wide_int num, register int nbits, char format, char *buf_end, register size_t *len) /* {{{ */
PHPAPI char * ap_php_conv_p2(register u_wide_int num, register int nbits, char format, char *buf_end, register size_t *len) /* {{{ */
{
register int mask = (1 << nbits) - 1;
register char *p = buf_end;

View file

@ -153,10 +153,10 @@ typedef enum {
typedef WIDE_INT wide_int;
typedef unsigned WIDE_INT u_wide_int;
extern char * ap_php_conv_10(register wide_int num, register bool_int is_unsigned,
PHPAPI char * ap_php_conv_10(register wide_int num, register bool_int is_unsigned,
register bool_int * is_negative, char *buf_end, register size_t *len);
extern char * ap_php_conv_p2(register u_wide_int num, register int nbits,
PHPAPI char * ap_php_conv_p2(register u_wide_int num, register int nbits,
char format, char *buf_end, register size_t *len);
/* The maximum precision that's allowed for float conversion. Does not include

View file

@ -101,13 +101,13 @@ enum php_stream_xport_send_recv_flags {
/* Similar to recv() system call; read data from the stream, optionally
* peeking, optionally retrieving OOB data */
PHPAPI int php_stream_xport_recvfrom(php_stream *stream, char *buf, size_t buflen,
long flags, void **addr, socklen_t *addrlen,
int flags, void **addr, socklen_t *addrlen,
zend_string **textaddr TSRMLS_DC);
/* Similar to send() system call; send data to the stream, optionally
* sending it as OOB data */
PHPAPI int php_stream_xport_sendto(php_stream *stream, const char *buf, size_t buflen,
long flags, void *addr, socklen_t addrlen TSRMLS_DC);
int flags, void *addr, socklen_t addrlen TSRMLS_DC);
typedef enum {
STREAM_SHUT_RD,
@ -146,9 +146,9 @@ typedef struct _php_stream_xport_param {
struct sockaddr *addr;
char *buf;
size_t buflen;
zend_long flags;
socklen_t addrlen;
int backlog;
int flags;
} inputs;
struct {
php_stream *client;

View file

@ -41,6 +41,7 @@
#include "php_streams_int.h"
#ifdef PHP_WIN32
# include "win32/winutil.h"
# include "win32/time.h"
#endif
#define php_stream_fopen_from_fd_int(fd, mode, persistent_id) _php_stream_fopen_from_fd_int((fd), (mode), (persistent_id) STREAMS_CC TSRMLS_CC)

View file

@ -393,7 +393,7 @@ PHPAPI int php_stream_xport_crypto_enable(php_stream *stream, int activate TSRML
/* Similar to recv() system call; read data from the stream, optionally
* peeking, optionally retrieving OOB data */
PHPAPI int php_stream_xport_recvfrom(php_stream *stream, char *buf, size_t buflen,
long flags, void **addr, socklen_t *addrlen, zend_string **textaddr
int flags, void **addr, socklen_t *addrlen, zend_string **textaddr
TSRMLS_DC)
{
php_stream_xport_param param;
@ -462,7 +462,7 @@ PHPAPI int php_stream_xport_recvfrom(php_stream *stream, char *buf, size_t bufle
/* Similar to send() system call; send data to the stream, optionally
* sending it as OOB data */
PHPAPI int php_stream_xport_sendto(php_stream *stream, const char *buf, size_t buflen,
long flags, void *addr, socklen_t addrlen TSRMLS_DC)
int flags, void *addr, socklen_t addrlen TSRMLS_DC)
{
php_stream_xport_param param;
int ret = 0;

View file

@ -3,12 +3,15 @@ dnl $Id$
dnl
PHP_ARG_ENABLE(phpdbg, for phpdbg support,
[ --enable-phpdbg Build phpdbg], no, no)
[ --enable-phpdbg Build phpdbg], no, no)
PHP_ARG_ENABLE(phpdbg-webhelper, for phpdbg web SAPI support,
[ --enable-phpdbg-webhelper Build phpdbg web SAPI support], yes, yes)
PHP_ARG_ENABLE(phpdbg-debug, for phpdbg debug build,
[ --enable-phpdbg-debug Build phpdbg in debug mode], no, no)
[ --enable-phpdbg-debug Build phpdbg in debug mode], no, no)
if test "$PHP_PHPDBG" != "no"; then
if test "$BUILD_PHPDBG" == "" && test "$PHP_PHPDBG" != "no"; then
AC_HEADER_TIOCGWINSZ
AC_DEFINE(HAVE_PHPDBG, 1, [ ])
@ -18,8 +21,19 @@ if test "$PHP_PHPDBG" != "no"; then
AC_DEFINE(PHPDBG_DEBUG, 0, [ ])
fi
if test "$PHP_PHPDBG_WEBHELPER" != "no"; then
if ! test -d ext/phpdbg_webhelper; then
ln -s ../sapi/phpdbg ext/phpdbg_webhelper
fi
if test "$PHP_JSON" != "no"; then
PHP_NEW_EXTENSION(phpdbg_webhelper, phpdbg_rinit_hook.c phpdbg_webdata_transfer.c, $ext_shared)
else
AC_MSG_ERROR(Webhelper extension of phpdbg needs json enabled)
fi
fi
PHP_PHPDBG_CFLAGS="-D_GNU_SOURCE"
PHP_PHPDBG_FILES="phpdbg.c phpdbg_parser.c phpdbg_lexer.c phpdbg_prompt.c phpdbg_help.c phpdbg_break.c phpdbg_print.c phpdbg_bp.c phpdbg_opcode.c phpdbg_list.c phpdbg_utils.c phpdbg_info.c phpdbg_cmd.c phpdbg_set.c phpdbg_frame.c phpdbg_watch.c phpdbg_btree.c"
PHP_PHPDBG_FILES="phpdbg.c phpdbg_parser.c phpdbg_lexer.c phpdbg_prompt.c phpdbg_help.c phpdbg_break.c phpdbg_print.c phpdbg_bp.c phpdbg_opcode.c phpdbg_list.c phpdbg_utils.c phpdbg_info.c phpdbg_cmd.c phpdbg_set.c phpdbg_frame.c phpdbg_watch.c phpdbg_btree.c phpdbg_sigsafe.c phpdbg_wait.c phpdbg_io.c phpdbg_eol.c phpdbg_out.c"
if test "$PHP_READLINE" != "no" -o "$PHP_LIBEDIT" != "no"; then
PHPDBG_EXTRA_LIBS="$PHP_READLINE_LIBS"

View file

@ -1,7 +1,11 @@
ARG_ENABLE('phpdbg', 'Build phpdbg', 'no');
ARG_ENABLE('phpdbgs', 'Build phpdbg shared', 'no');
PHPDBG_SOURCES='phpdbg.c phpdbg_prompt.c phpdbg_cmd.c phpdbg_info.c phpdbg_help.c phpdbg_break.c phpdbg_print.c phpdbg_bp.c phpdbg_opcode.c phpdbg_list.c phpdbg_utils.c phpdbg_set.c phpdbg_frame.c phpdbg_watch.c phpdbg_win.c phpdbg_btree.c phpdbg_parser.c phpdbg_lexer.c';
PHPDBG_SOURCES='phpdbg.c phpdbg_prompt.c phpdbg_cmd.c phpdbg_info.c phpdbg_help.c phpdbg_break.c ' +
'phpdbg_print.c phpdbg_bp.c phpdbg_opcode.c phpdbg_list.c phpdbg_utils.c ' +
'phpdbg_set.c phpdbg_frame.c phpdbg_watch.c phpdbg_win.c phpdbg_btree.c '+
'phpdbg_parser.c phpdbg_lexer.c phpdbg_sigsafe.c phpdbg_wait.c phpdbg_io.c ' +
'phpdbg_sigio_win32.c phpdbg_eol.c phpdbg_out.c';
PHPDBG_DLL='php' + PHP_VERSION + 'phpdbg.dll';
PHPDBG_EXE='phpdbg.exe';
@ -9,6 +13,7 @@ if (PHP_PHPDBG == "yes") {
SAPI('phpdbg', PHPDBG_SOURCES, PHPDBG_EXE);
ADD_FLAG("LIBS_PHPDBG", "ws2_32.lib user32.lib");
ADD_FLAG("CFLAGS_PHPDBG", "/D YY_NO_UNISTD_H");
ADD_FLAG("LDFLAGS_PHPDBG", "/stack:8388608");
}
if (PHP_PHPDBGS == "yes") {

View file

@ -7,7 +7,7 @@ phpdbg \- The interactive PHP debugger
[\fB\-e\fIFILE\fR]
.SH DESCRIPTION
.B phpdbg
a lightweight, powerful, easy to use debugging platform for PHP7.
a lightweight, powerful, easy to use debugging platform for PHP5.
.SH OPTIONS
The following switches are implemented (just like cli SAPI):
.TP

File diff suppressed because it is too large Load diff

View file

@ -1,6 +1,6 @@
/*
+----------------------------------------------------------------------+
| PHP Version 7 |
| PHP Version 5 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2014 The PHP Group |
+----------------------------------------------------------------------+
@ -29,6 +29,8 @@
# define PHPDBG_API
#endif
#include <stdint.h>
#include <stddef.h>
#include "php.h"
#include "php_globals.h"
#include "php_variables.h"
@ -40,20 +42,21 @@
#include "zend_ini_scanner.h"
#include "zend_stream.h"
#ifndef _WIN32
# include "zend_signal.h"
# include "zend_signal.h"
#endif
#include "SAPI.h"
#include <fcntl.h>
#include <sys/types.h>
#if defined(_WIN32) && !defined(__MINGW32__)
# include <windows.h>
# include "config.w32.h"
# undef strcasecmp
# undef strncasecmp
# define strcasecmp _stricmp
# define strncasecmp _strnicmp
# include <windows.h>
# include "config.w32.h"
# include "win32/php_stdint.h"
# undef strcasecmp
# undef strncasecmp
# define strcasecmp _stricmp
# define strncasecmp _strnicmp
#else
# include "php_config.h"
# include "php_config.h"
#endif
#ifndef O_BINARY
# define O_BINARY 0
@ -64,21 +67,64 @@
# include "TSRM.h"
#endif
#ifdef LIBREADLINE
# include <readline/readline.h>
# include <readline/history.h>
#define ZEND_HASH_FOREACH_NUM_KEY_PTR(ht, _h, _ptr) \
ZEND_HASH_FOREACH(ht, 0); \
_h = _p->h; \
_ptr = Z_PTR_P(_z);
#undef zend_hash_str_add
#define zend_hash_str_add_tmp(ht, key, len, pData) \
_zend_hash_str_add(ht, key, len, pData ZEND_FILE_LINE_CC)
#define zend_hash_str_add(...) zend_hash_str_add_tmp(__VA_ARGS__)
static zend_always_inline void *zend_hash_index_add_mem(HashTable *ht, zend_ulong h, void *pData, size_t size)
{
zval tmp, *zv;
ZVAL_PTR(&tmp, NULL);
if ((zv = zend_hash_index_add(ht, h, &tmp))) {
Z_PTR_P(zv) = pemalloc(size, ht->u.flags & HASH_FLAG_PERSISTENT);
memcpy(Z_PTR_P(zv), pData, size);
return Z_PTR_P(zv);
}
return NULL;
}
#ifdef HAVE_LIBREADLINE
# include <readline/readline.h>
# include <readline/history.h>
#endif
#ifdef HAVE_LIBEDIT
# include <editline/readline.h>
# include <editline/readline.h>
#endif
#include "phpdbg_lexer.h"
#include "phpdbg_cmd.h"
#include "phpdbg_utils.h"
#include "phpdbg_btree.h"
#include "phpdbg_watch.h"
/* {{{ remote console headers */
#ifndef _WIN32
# include <sys/socket.h>
# include <sys/un.h>
# include <sys/select.h>
# include <sys/types.h>
# include <netdb.h>
#endif /* }}} */
int phpdbg_do_parse(phpdbg_param_t *stack, char *input TSRMLS_DC);
/* {{{ strings */
#define PHPDBG_NAME "phpdbg"
#define PHPDBG_AUTHORS "Felipe Pena, Joe Watkins and Bob Weinand" /* Ordered by last name */
#define PHPDBG_URL "http://phpdbg.com"
#define PHPDBG_ISSUES "http://github.com/krakjoe/phpdbg/issues"
#define PHPDBG_VERSION "0.4.0"
#define PHPDBG_INIT_FILENAME ".phpdbginit"
#define PHPDBG_DEFAULT_PROMPT "prompt>"
/* }}} */
/* Hey, apple. One shouldn't define *functions* from the standard C library as marcos. */
#ifdef memcpy
#define memcpy_tmp(...) memcpy(__VA_ARGS__)
#undef memcpy
#define memcpy(...) memcpy_tmp(__VA_ARGS__)
#endif
#if !defined(PHPDBG_WEBDATA_TRANSFER_H) && !defined(PHPDBG_WEBHELPER_H)
#ifdef ZTS
# define PHPDBG_G(v) TSRMG(phpdbg_globals_id, zend_phpdbg_globals *, v)
@ -86,6 +132,19 @@ int phpdbg_do_parse(phpdbg_param_t *stack, char *input TSRMLS_DC);
# define PHPDBG_G(v) (phpdbg_globals.v)
#endif
#include "phpdbg_sigsafe.h"
#include "phpdbg_out.h"
#include "phpdbg_lexer.h"
#include "phpdbg_cmd.h"
#include "phpdbg_utils.h"
#include "phpdbg_btree.h"
#include "phpdbg_watch.h"
#ifdef PHP_WIN32
# include "phpdbg_sigio_win32.h"
#endif
int phpdbg_do_parse(phpdbg_param_t *stack, char *input TSRMLS_DC);
#define PHPDBG_NEXT 2
#define PHPDBG_UNTIL 3
#define PHPDBG_FINISH 4
@ -145,11 +204,14 @@ int phpdbg_do_parse(phpdbg_param_t *stack, char *input TSRMLS_DC);
#define PHPDBG_IS_BP_ENABLED (1<<26)
#define PHPDBG_IS_REMOTE (1<<27)
#define PHPDBG_IS_DISCONNECTED (1<<28)
#define PHPDBG_WRITE_XML (1<<29)
#define PHPDBG_SHOW_REFCOUNTS (1<<29)
#define PHPDBG_SHOW_REFCOUNTS (1<<30)
#define PHPDBG_IN_SIGNAL_HANDLER (1<<30)
#define PHPDBG_SEEK_MASK (PHPDBG_IN_UNTIL|PHPDBG_IN_FINISH|PHPDBG_IN_LEAVE)
#define PHPDBG_BP_RESOLVE_MASK (PHPDBG_HAS_FUNCTION_OPLINE_BP|PHPDBG_HAS_METHOD_OPLINE_BP|PHPDBG_HAS_FILE_OPLINE_BP)
#define PHPDBG_BP_RESOLVE_MASK (PHPDBG_HAS_FUNCTION_OPLINE_BP|PHPDBG_HAS_METHOD_OPLINE_BP|PHPDBG_HAS_FILE_OPLINE_BP)
#define PHPDBG_BP_MASK (PHPDBG_HAS_FILE_BP|PHPDBG_HAS_SYM_BP|PHPDBG_HAS_METHOD_BP|PHPDBG_HAS_OPLINE_BP|PHPDBG_HAS_COND_BP|PHPDBG_HAS_OPCODE_BP|PHPDBG_HAS_FUNCTION_OPLINE_BP|PHPDBG_HAS_METHOD_OPLINE_BP|PHPDBG_HAS_FILE_OPLINE_BP)
#ifndef _WIN32
@ -158,21 +220,27 @@ int phpdbg_do_parse(phpdbg_param_t *stack, char *input TSRMLS_DC);
# define PHPDBG_DEFAULT_FLAGS (PHPDBG_IS_QUIET|PHPDBG_IS_BP_ENABLED)
#endif /* }}} */
/* {{{ strings */
#define PHPDBG_NAME "phpdbg"
#define PHPDBG_AUTHORS "Felipe Pena, Joe Watkins and Bob Weinand" /* Ordered by last name */
#define PHPDBG_URL "http://phpdbg.com"
#define PHPDBG_ISSUES "http://github.com/krakjoe/phpdbg/issues"
#define PHPDBG_VERSION "0.4.0"
#define PHPDBG_INIT_FILENAME ".phpdbginit"
/* }}} */
/* {{{ output descriptors */
#define PHPDBG_STDIN 0
#define PHPDBG_STDOUT 1
#define PHPDBG_STDERR 2
#define PHPDBG_IO_FDS 3 /* }}} */
#define phpdbg_try_access \
{ \
JMP_BUF *__orig_bailout = PHPDBG_G(sigsegv_bailout); \
JMP_BUF __bailout; \
\
PHPDBG_G(sigsegv_bailout) = &__bailout; \
if (SETJMP(__bailout) == 0) {
#define phpdbg_catch_access \
} else { \
PHPDBG_G(sigsegv_bailout) = __orig_bailout;
#define phpdbg_end_try_access() \
} \
PHPDBG_G(sigsegv_bailout) = __orig_bailout; \
}
/* {{{ structs */
ZEND_BEGIN_MODULE_GLOBALS(phpdbg)
@ -180,7 +248,7 @@ ZEND_BEGIN_MODULE_GLOBALS(phpdbg)
HashTable registered; /* registered */
HashTable seek; /* seek oplines */
phpdbg_frame_t frame; /* frame */
uint32_t last_line; /* last executed line */
uint32_t last_line; /* last executed line */
phpdbg_lexer_data lexer; /* lexer data */
phpdbg_param_t *parser_stack; /* param stack during lexer / parser phase */
@ -191,6 +259,7 @@ ZEND_BEGIN_MODULE_GLOBALS(phpdbg)
phpdbg_btree watchpoint_tree; /* tree with watchpoints */
phpdbg_btree watch_HashTables; /* tree with original dtors of watchpoints */
HashTable watchpoints; /* watchpoints */
HashTable watch_collisions; /* collision table to check if multiple watches share the same recursive watchpoint */
zend_llist watchlist_mem; /* triggered watchpoints */
zend_bool watchpoint_hit; /* a watchpoint was hit */
void (*original_free_function)(void *); /* the original AG(mm_heap)->_free function */
@ -198,33 +267,57 @@ ZEND_BEGIN_MODULE_GLOBALS(phpdbg)
char *exec; /* file to execute */
size_t exec_len; /* size of exec */
zend_op_array *ops; /* op_array */
zval *retval; /* return value */
zval retval; /* return value */
int bp_count; /* breakpoint count */
int vmret; /* return from last opcode handler execution */
zend_bool in_execution; /* in execution? */
zend_op_array *(*compile_file)(zend_file_handle *file_handle, int type TSRMLS_DC);
HashTable file_sources;
FILE *oplog; /* opline log */
FILE *io[PHPDBG_IO_FDS]; /* io */
struct {
FILE *ptr;
int fd;
} io[PHPDBG_IO_FDS]; /* io */
size_t (*php_stdiop_write)(php_stream *, const char *, size_t TSRMLS_DC);
int in_script_xml; /* in <stream> output mode */
struct {
zend_bool active;
int type;
int fd;
char *tag;
char *msg;
int msglen;
char *xml;
int xmllen;
} err_buf; /* error buffer */
zend_ulong req_id; /* "request id" to keep track of commands */
char *prompt[2]; /* prompt */
const phpdbg_color_t *colors[PHPDBG_COLORS]; /* colors */
char *buffer; /* buffer */
zend_bool last_was_newline; /* check if we don't need to output a newline upon next phpdbg_error or phpdbg_notice */
char input_buffer[PHPDBG_MAX_CMD]; /* stdin input buffer */
int input_buflen; /* length of stdin input buffer */
phpdbg_signal_safe_mem sigsafe_mem; /* memory to use in async safe environment (only once!) */
JMP_BUF *sigsegv_bailout; /* bailout address for accesibility probing */
zend_ulong flags; /* phpdbg flags */
char *socket_path; /* phpdbg.path ini setting */
char *sapi_name_ptr; /* store sapi name to free it if necessary to not leak memory */
int socket_fd; /* file descriptor to socket (wait command) (-1 if unused) */
int socket_server_fd; /* file descriptor to master socket (wait command) (-1 if unused) */
#ifdef PHP_WIN32
HANDLE sigio_watcher_thread; /* sigio watcher thread handle */
struct win32_sigio_watcher_data swd;
#endif
int8_t eol;
ZEND_END_MODULE_GLOBALS(phpdbg) /* }}} */
/* the beginning (= the important part) of the _zend_mm_heap struct defined in Zend/zend_alloc.c
Needed for realizing watchpoints */
struct _zend_mm_heap {
int use_zend_alloc;
void *(*_malloc)(size_t);
void (*_free)(void *);
void *(*_realloc)(void *, size_t);
size_t free_bitmap;
size_t large_free_bitmap;
size_t block_size;
size_t compact_size;
zend_mm_segment *segments_list;
zend_mm_storage *storage;
};
#endif
#endif /* PHPDBG_H */

File diff suppressed because it is too large Load diff

View file

@ -1,6 +1,6 @@
/*
+----------------------------------------------------------------------+
| PHP Version 7 |
| PHP Version 5 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2014 The PHP Group |
+----------------------------------------------------------------------+
@ -21,6 +21,19 @@
#ifndef PHPDBG_BP_H
#define PHPDBG_BP_H
/* {{{ defines */
#define PHPDBG_BREAK_FILE 0
#define PHPDBG_BREAK_SYM 1
#define PHPDBG_BREAK_OPLINE 2
#define PHPDBG_BREAK_METHOD 3
#define PHPDBG_BREAK_COND 4
#define PHPDBG_BREAK_OPCODE 5
#define PHPDBG_BREAK_FUNCTION_OPLINE 6
#define PHPDBG_BREAK_METHOD_OPLINE 7
#define PHPDBG_BREAK_FILE_OPLINE 8
#define PHPDBG_BREAK_MAP 9
#define PHPDBG_BREAK_TABLES 10 /* }}} */
/* {{{ */
typedef struct _zend_op *phpdbg_opline_ptr_t; /* }}} */
@ -138,7 +151,7 @@ PHPDBG_API void phpdbg_disable_breakpoints(TSRMLS_D); /* }}} */
/* {{{ Breakbase API */
PHPDBG_API phpdbg_breakbase_t *phpdbg_find_breakbase(zend_ulong id TSRMLS_DC);
PHPDBG_API phpdbg_breakbase_t *phpdbg_find_breakbase_ex(zend_ulong id, HashTable ***table, HashPosition *position TSRMLS_DC); /* }}} */
PHPDBG_API phpdbg_breakbase_t *phpdbg_find_breakbase_ex(zend_ulong id, HashTable **table, zend_ulong *numkey, zend_string **strkey TSRMLS_DC); /* }}} */
/* {{{ Breakpoint Exportation API */
PHPDBG_API void phpdbg_export_breakpoints(FILE *handle TSRMLS_DC); /* }}} */

View file

@ -1,6 +1,6 @@
/*
+----------------------------------------------------------------------+
| PHP Version 7 |
| PHP Version 5 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2014 The PHP Group |
+----------------------------------------------------------------------+
@ -28,15 +28,15 @@
ZEND_EXTERN_MODULE_GLOBALS(phpdbg);
#define PHPDBG_BREAK_COMMAND_D(f, h, a, m, l, s) \
PHPDBG_COMMAND_D_EXP(f, h, a, m, l, s, &phpdbg_prompt_commands[10])
#define PHPDBG_BREAK_COMMAND_D(f, h, a, m, l, s, flags) \
PHPDBG_COMMAND_D_EXP(f, h, a, m, l, s, &phpdbg_prompt_commands[10], flags)
/**
* Commands
*/
const phpdbg_command_t phpdbg_break_commands[] = {
PHPDBG_BREAK_COMMAND_D(at, "specify breakpoint by location and condition", '@', break_at, NULL, "*c"),
PHPDBG_BREAK_COMMAND_D(del, "delete breakpoint by identifier number", '~', break_del, NULL, "n"),
PHPDBG_BREAK_COMMAND_D(at, "specify breakpoint by location and condition", '@', break_at, NULL, "*c", 0),
PHPDBG_BREAK_COMMAND_D(del, "delete breakpoint by identifier number", '~', break_del, NULL, "n", 0),
PHPDBG_END_COMMAND
};

View file

@ -1,6 +1,6 @@
/*
+----------------------------------------------------------------------+
| PHP Version 7 |
| PHP Version 5 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2014 The PHP Group |
+----------------------------------------------------------------------+

View file

@ -1,6 +1,6 @@
/*
+----------------------------------------------------------------------+
| PHP Version 7 |
| PHP Version 5 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2014 The PHP Group |
+----------------------------------------------------------------------+
@ -219,3 +219,18 @@ check_branch_existence:
return SUCCESS;
}
void phpdbg_btree_branch_dump(phpdbg_btree_branch *branch, zend_ulong depth) {
if (branch) {
if (depth--) {
phpdbg_btree_branch_dump(branch->branches[0], depth);
phpdbg_btree_branch_dump(branch->branches[1], depth);
} else {
fprintf(stderr, "%p: %p\n", (void *) branch->result.idx, branch->result.ptr);
}
}
}
void phpdbg_btree_dump(phpdbg_btree *tree) {
phpdbg_btree_branch_dump(tree->branch, tree->depth);
}

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