mirror of
https://github.com/php/php-src.git
synced 2026-03-24 00:02:20 +01:00
Keep initialized object_handlers structures in read-only memory.
This commit is contained in:
@@ -27,7 +27,7 @@ static zend_class_entry zend_iterator_class_entry;
|
||||
static void iter_wrapper_free(zend_object *object);
|
||||
static void iter_wrapper_dtor(zend_object *object);
|
||||
|
||||
static zend_object_handlers iterator_object_handlers = {
|
||||
static const zend_object_handlers iterator_object_handlers = {
|
||||
0,
|
||||
iter_wrapper_free,
|
||||
iter_wrapper_dtor,
|
||||
|
||||
@@ -1733,7 +1733,7 @@ int zend_std_get_closure(zval *obj, zend_class_entry **ce_ptr, zend_function **f
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
ZEND_API zend_object_handlers std_object_handlers = {
|
||||
ZEND_API const zend_object_handlers std_object_handlers = {
|
||||
0, /* offset */
|
||||
|
||||
zend_object_std_dtor, /* free_obj */
|
||||
|
||||
@@ -165,7 +165,7 @@ struct _zend_object_handlers {
|
||||
};
|
||||
|
||||
BEGIN_EXTERN_C()
|
||||
extern ZEND_API zend_object_handlers std_object_handlers;
|
||||
extern const ZEND_API zend_object_handlers std_object_handlers;
|
||||
|
||||
#define zend_get_function_root_class(fbc) \
|
||||
((fbc)->common.prototype ? (fbc)->common.prototype->common.scope : (fbc)->common.scope)
|
||||
|
||||
@@ -197,7 +197,7 @@ ZEND_API void ZEND_FASTCALL zend_objects_store_del(zend_object *object) /* {{{ *
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
ZEND_API zend_object_handlers* ZEND_FASTCALL zend_get_std_object_handlers(void)
|
||||
ZEND_API const zend_object_handlers* ZEND_FASTCALL zend_get_std_object_handlers(void)
|
||||
{
|
||||
return &std_object_handlers;
|
||||
}
|
||||
|
||||
@@ -67,7 +67,7 @@ static zend_always_inline void zend_object_store_ctor_failed(zend_object *obj)
|
||||
|
||||
#define ZEND_OBJECTS_STORE_HANDLERS 0, zend_object_std_dtor, zend_objects_destroy_object, zend_objects_clone_obj
|
||||
|
||||
ZEND_API zend_object_handlers * ZEND_FASTCALL zend_get_std_object_handlers(void);
|
||||
ZEND_API const zend_object_handlers * ZEND_FASTCALL zend_get_std_object_handlers(void);
|
||||
END_EXTERN_C()
|
||||
|
||||
static zend_always_inline void zend_object_release(zend_object *obj)
|
||||
|
||||
@@ -319,7 +319,7 @@ static zval *dom_get_property_ptr_ptr(zval *object, zval *member, int type, void
|
||||
zval *retval = NULL;
|
||||
|
||||
if (!obj->prop_handler || !zend_hash_exists(obj->prop_handler, member_str)) {
|
||||
zend_object_handlers *std_hnd = zend_get_std_object_handlers();
|
||||
const zend_object_handlers *std_hnd = zend_get_std_object_handlers();
|
||||
retval = std_hnd->get_property_ptr_ptr(object, member, type, cache_slot);
|
||||
}
|
||||
|
||||
@@ -350,7 +350,7 @@ zval *dom_read_property(zval *object, zval *member, int type, void **cache_slot,
|
||||
retval = &EG(uninitialized_zval);
|
||||
}
|
||||
} else {
|
||||
zend_object_handlers *std_hnd = zend_get_std_object_handlers();
|
||||
const zend_object_handlers *std_hnd = zend_get_std_object_handlers();
|
||||
retval = std_hnd->read_property(object, member, type, cache_slot, rv);
|
||||
}
|
||||
|
||||
@@ -372,7 +372,7 @@ void dom_write_property(zval *object, zval *member, zval *value, void **cache_sl
|
||||
if (hnd) {
|
||||
hnd->write_func(obj, value);
|
||||
} else {
|
||||
zend_object_handlers *std_hnd = zend_get_std_object_handlers();
|
||||
const zend_object_handlers *std_hnd = zend_get_std_object_handlers();
|
||||
std_hnd->write_property(object, member, value, cache_slot);
|
||||
}
|
||||
|
||||
@@ -405,7 +405,7 @@ static int dom_property_exists(zval *object, zval *member, int check_empty, void
|
||||
zval_dtor(&tmp);
|
||||
}
|
||||
} else {
|
||||
zend_object_handlers *std_hnd = zend_get_std_object_handlers();
|
||||
const zend_object_handlers *std_hnd = zend_get_std_object_handlers();
|
||||
retval = std_hnd->has_property(object, member, check_empty, cache_slot);
|
||||
}
|
||||
|
||||
|
||||
@@ -321,7 +321,7 @@ zval *mysqli_read_property(zval *object, zval *member, int type, void **cache_sl
|
||||
retval = &EG(uninitialized_zval);
|
||||
}
|
||||
} else {
|
||||
zend_object_handlers *std_hnd = zend_get_std_object_handlers();
|
||||
const zend_object_handlers *std_hnd = zend_get_std_object_handlers();
|
||||
retval = std_hnd->read_property(object, member, type, cache_slot, rv);
|
||||
}
|
||||
|
||||
@@ -354,7 +354,7 @@ void mysqli_write_property(zval *object, zval *member, zval *value, void **cache
|
||||
if (hnd) {
|
||||
hnd->write_func(obj, value);
|
||||
} else {
|
||||
zend_object_handlers *std_hnd = zend_get_std_object_handlers();
|
||||
const zend_object_handlers *std_hnd = zend_get_std_object_handlers();
|
||||
std_hnd->write_property(object, member, value, cache_slot);
|
||||
}
|
||||
|
||||
@@ -409,7 +409,7 @@ static int mysqli_object_has_property(zval *object, zval *member, int has_set_ex
|
||||
php_error_docref(NULL, E_WARNING, "Invalid value for has_set_exists");
|
||||
}
|
||||
} else {
|
||||
zend_object_handlers *std_hnd = zend_get_std_object_handlers();
|
||||
const zend_object_handlers *std_hnd = zend_get_std_object_handlers();
|
||||
ret = std_hnd->has_property(object, member, has_set_exists, cache_slot);
|
||||
}
|
||||
|
||||
@@ -561,7 +561,7 @@ static PHP_GINIT_FUNCTION(mysqli)
|
||||
PHP_MINIT_FUNCTION(mysqli)
|
||||
{
|
||||
zend_class_entry *ce,cex;
|
||||
zend_object_handlers *std_hnd = zend_get_std_object_handlers();
|
||||
const zend_object_handlers *std_hnd = zend_get_std_object_handlers();
|
||||
|
||||
REGISTER_INI_ENTRIES();
|
||||
#ifndef MYSQLI_USE_MYSQLND
|
||||
|
||||
@@ -2668,7 +2668,7 @@ static int row_compare(zval *object1, zval *object2)
|
||||
return -1;
|
||||
}
|
||||
|
||||
zend_object_handlers pdo_row_object_handlers = {
|
||||
const zend_object_handlers pdo_row_object_handlers = {
|
||||
0,
|
||||
zend_objects_destroy_object,
|
||||
pdo_row_free_storage,
|
||||
|
||||
@@ -51,7 +51,7 @@ extern zend_object *pdo_row_new(zend_class_entry *ce);
|
||||
extern const zend_function_entry pdo_row_functions[];
|
||||
extern zend_class_entry *pdo_row_ce;
|
||||
void pdo_row_free_storage(zend_object *std);
|
||||
extern zend_object_handlers pdo_row_object_handlers;
|
||||
extern const zend_object_handlers pdo_row_object_handlers;
|
||||
|
||||
zend_object_iterator *php_pdo_dbstmt_iter_get(zend_class_entry *ce, zval *object);
|
||||
|
||||
|
||||
@@ -6694,7 +6694,7 @@ static const zend_function_entry reflection_ext_functions[] = { /* {{{ */
|
||||
PHP_FE_END
|
||||
}; /* }}} */
|
||||
|
||||
static zend_object_handlers *zend_std_obj_handlers;
|
||||
static const zend_object_handlers *zend_std_obj_handlers;
|
||||
|
||||
/* {{{ _reflection_write_property */
|
||||
static void _reflection_write_property(zval *object, zval *member, zval *value, void **cache_slot)
|
||||
|
||||
@@ -2009,34 +2009,7 @@ static zval *sxe_get_value(zval *z, zval *rv) /* {{{ */
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
static zend_object_handlers sxe_object_handlers = { /* {{{ */
|
||||
ZEND_OBJECTS_STORE_HANDLERS,
|
||||
sxe_property_read,
|
||||
sxe_property_write,
|
||||
sxe_dimension_read,
|
||||
sxe_dimension_write,
|
||||
sxe_property_get_adr,
|
||||
sxe_get_value, /* get */
|
||||
NULL,
|
||||
sxe_property_exists,
|
||||
sxe_property_delete,
|
||||
sxe_dimension_exists,
|
||||
sxe_dimension_delete,
|
||||
sxe_get_properties,
|
||||
NULL, /* zend_get_std_object_handlers()->get_method,*/
|
||||
NULL, /* zend_get_std_object_handlers()->call_method,*/
|
||||
NULL, /* zend_get_std_object_handlers()->get_constructor, */
|
||||
NULL, /* zend_get_std_object_handlers()->get_class_name,*/
|
||||
sxe_objects_compare,
|
||||
sxe_object_cast,
|
||||
sxe_count_elements,
|
||||
sxe_get_debug_info,
|
||||
NULL,
|
||||
sxe_get_gc,
|
||||
NULL,
|
||||
NULL
|
||||
};
|
||||
/* }}} */
|
||||
static zend_object_handlers sxe_object_handlers;
|
||||
|
||||
/* {{{ sxe_object_clone()
|
||||
*/
|
||||
@@ -2715,13 +2688,30 @@ PHP_MINIT_FUNCTION(simplexml)
|
||||
sxe_class_entry->get_iterator = php_sxe_get_iterator;
|
||||
sxe_class_entry->iterator_funcs.funcs = &php_sxe_iterator_funcs;
|
||||
zend_class_implements(sxe_class_entry, 1, zend_ce_traversable);
|
||||
|
||||
memcpy(&sxe_object_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
|
||||
sxe_object_handlers.offset = XtOffsetOf(php_sxe_object, zo);
|
||||
sxe_object_handlers.dtor_obj = sxe_object_dtor;
|
||||
sxe_object_handlers.free_obj = sxe_object_free_storage;
|
||||
sxe_object_handlers.clone_obj = sxe_object_clone;
|
||||
sxe_object_handlers.get_method = zend_get_std_object_handlers()->get_method;
|
||||
sxe_object_handlers.get_constructor = zend_get_std_object_handlers()->get_constructor;
|
||||
sxe_object_handlers.get_class_name = zend_get_std_object_handlers()->get_class_name;
|
||||
sxe_object_handlers.read_property = sxe_property_read;
|
||||
sxe_object_handlers.write_property = sxe_property_write;
|
||||
sxe_object_handlers.read_dimension = sxe_dimension_read;
|
||||
sxe_object_handlers.write_dimension = sxe_dimension_write;
|
||||
sxe_object_handlers.get_property_ptr_ptr = sxe_property_get_adr;
|
||||
sxe_object_handlers.get = sxe_get_value;
|
||||
sxe_object_handlers.has_property = sxe_property_exists;
|
||||
sxe_object_handlers.unset_property = sxe_property_delete;
|
||||
sxe_object_handlers.has_dimension = sxe_dimension_exists;
|
||||
sxe_object_handlers.unset_dimension = sxe_dimension_delete;
|
||||
sxe_object_handlers.get_properties = sxe_get_properties;
|
||||
sxe_object_handlers.compare_objects = sxe_objects_compare;
|
||||
sxe_object_handlers.cast_object = sxe_object_cast;
|
||||
sxe_object_handlers.count_elements = sxe_count_elements;
|
||||
sxe_object_handlers.get_debug_info = sxe_get_debug_info;
|
||||
sxe_object_handlers.get_closure = NULL;
|
||||
sxe_object_handlers.get_gc = sxe_get_gc;
|
||||
|
||||
sxe_class_entry->serialize = zend_class_serialize_deny;
|
||||
sxe_class_entry->unserialize = zend_class_unserialize_deny;
|
||||
|
||||
|
||||
@@ -1938,7 +1938,7 @@ zval *php_snmp_read_property(zval *object, zval *member, int type, void **cache_
|
||||
retval = &EG(uninitialized_zval);
|
||||
}
|
||||
} else {
|
||||
zend_object_handlers * std_hnd = zend_get_std_object_handlers();
|
||||
const zend_object_handlers * std_hnd = zend_get_std_object_handlers();
|
||||
retval = std_hnd->read_property(object, member, type, cache_slot, rv);
|
||||
}
|
||||
|
||||
@@ -1976,7 +1976,7 @@ void php_snmp_write_property(zval *object, zval *member, zval *value, void **cac
|
||||
}
|
||||
*/
|
||||
} else {
|
||||
zend_object_handlers * std_hnd = zend_get_std_object_handlers();
|
||||
const zend_object_handlers * std_hnd = zend_get_std_object_handlers();
|
||||
std_hnd->write_property(object, member, value, cache_slot);
|
||||
}
|
||||
|
||||
@@ -2017,7 +2017,7 @@ static int php_snmp_has_property(zval *object, zval *member, int has_set_exists,
|
||||
}
|
||||
}
|
||||
} else {
|
||||
zend_object_handlers *std_hnd = zend_get_std_object_handlers();
|
||||
const zend_object_handlers *std_hnd = zend_get_std_object_handlers();
|
||||
ret = std_hnd->has_property(object, member, has_set_exists, cache_slot);
|
||||
}
|
||||
return ret;
|
||||
|
||||
@@ -122,7 +122,7 @@ zval *xmlreader_get_property_ptr_ptr(zval *object, zval *member, int type, void
|
||||
zval tmp_member;
|
||||
zval *retval = NULL;
|
||||
xmlreader_prop_handler *hnd = NULL;
|
||||
zend_object_handlers *std_hnd;
|
||||
const zend_object_handlers *std_hnd;
|
||||
|
||||
if (Z_TYPE_P(member) != IS_STRING) {
|
||||
ZVAL_STR(&tmp_member, zval_get_string_func(member));
|
||||
@@ -155,7 +155,7 @@ zval *xmlreader_read_property(zval *object, zval *member, int type, void **cache
|
||||
zval tmp_member;
|
||||
zval *retval = NULL;
|
||||
xmlreader_prop_handler *hnd = NULL;
|
||||
zend_object_handlers *std_hnd;
|
||||
const zend_object_handlers *std_hnd;
|
||||
|
||||
if (Z_TYPE_P(member) != IS_STRING) {
|
||||
ZVAL_STR(&tmp_member, zval_get_string_func(member));
|
||||
@@ -192,7 +192,7 @@ void xmlreader_write_property(zval *object, zval *member, zval *value, void **ca
|
||||
xmlreader_object *obj;
|
||||
zval tmp_member;
|
||||
xmlreader_prop_handler *hnd = NULL;
|
||||
zend_object_handlers *std_hnd;
|
||||
const zend_object_handlers *std_hnd;
|
||||
|
||||
if (Z_TYPE_P(member) != IS_STRING) {
|
||||
ZVAL_STR(&tmp_member, zval_get_string_func(member));
|
||||
|
||||
@@ -399,7 +399,7 @@ PHP_FUNCTION(xsl_xsltprocessor_import_stylesheet)
|
||||
xsl_object *intern;
|
||||
int prevSubstValue, prevExtDtdValue, clone_docu = 0;
|
||||
xmlNode *nodep = NULL;
|
||||
zend_object_handlers *std_hnd;
|
||||
const zend_object_handlers *std_hnd;
|
||||
zval *cloneDocu, member, rv;
|
||||
|
||||
if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Oo", &id, xsl_xsltprocessor_class_entry, &docp) == FAILURE) {
|
||||
@@ -483,7 +483,7 @@ static xmlDocPtr php_xsl_apply_stylesheet(zval *id, xsl_object *intern, xsltStyl
|
||||
char **params = NULL;
|
||||
int clone;
|
||||
zval *doXInclude, member, rv;
|
||||
zend_object_handlers *std_hnd;
|
||||
const zend_object_handlers *std_hnd;
|
||||
FILE *f;
|
||||
int secPrefsError = 0;
|
||||
int secPrefsValue;
|
||||
|
||||
@@ -878,7 +878,7 @@ static zval *php_zip_get_property_ptr_ptr(zval *object, zval *member, int type,
|
||||
zval tmp_member;
|
||||
zval *retval = NULL;
|
||||
zip_prop_handler *hnd = NULL;
|
||||
zend_object_handlers *std_hnd;
|
||||
const zend_object_handlers *std_hnd;
|
||||
|
||||
if (Z_TYPE_P(member) != IS_STRING) {
|
||||
ZVAL_STR(&tmp_member, zval_get_string_func(member));
|
||||
@@ -911,7 +911,7 @@ static zval *php_zip_read_property(zval *object, zval *member, int type, void **
|
||||
zval tmp_member;
|
||||
zval *retval = NULL;
|
||||
zip_prop_handler *hnd = NULL;
|
||||
zend_object_handlers *std_hnd;
|
||||
const zend_object_handlers *std_hnd;
|
||||
|
||||
if (Z_TYPE_P(member) != IS_STRING) {
|
||||
ZVAL_STR(&tmp_member, zval_get_string_func(member));
|
||||
@@ -948,7 +948,7 @@ static int php_zip_has_property(zval *object, zval *member, int type, void **cac
|
||||
ze_zip_object *obj;
|
||||
zval tmp_member;
|
||||
zip_prop_handler *hnd = NULL;
|
||||
zend_object_handlers *std_hnd;
|
||||
const zend_object_handlers *std_hnd;
|
||||
int retval = 0;
|
||||
|
||||
if (Z_TYPE_P(member) != IS_STRING) {
|
||||
|
||||
Reference in New Issue
Block a user