diff options
author | Dmitry Stogov <dmitry@zend.com> | 2018-03-14 14:01:45 +0300 |
---|---|---|
committer | Dmitry Stogov <dmitry@zend.com> | 2018-03-14 14:01:45 +0300 |
commit | 1af60a2a7127cd8a366f614b43566123c1dcc80a (patch) | |
tree | 303bf4026ad283e43159dd699fb6c67bd484b3d0 | |
parent | 12baec3dfa10a4ae87d90b0c785403d5b2303230 (diff) | |
download | php-git-1af60a2a7127cd8a366f614b43566123c1dcc80a.tar.gz |
Keep initialized object_handlers structures in read-only memory.
-rw-r--r-- | Zend/zend_iterators.c | 2 | ||||
-rw-r--r-- | Zend/zend_object_handlers.c | 2 | ||||
-rw-r--r-- | Zend/zend_object_handlers.h | 2 | ||||
-rw-r--r-- | Zend/zend_objects_API.c | 2 | ||||
-rw-r--r-- | Zend/zend_objects_API.h | 2 | ||||
-rw-r--r-- | ext/dom/php_dom.c | 8 | ||||
-rw-r--r-- | ext/mysqli/mysqli.c | 8 | ||||
-rw-r--r-- | ext/pdo/pdo_stmt.c | 2 | ||||
-rw-r--r-- | ext/pdo/php_pdo_int.h | 2 | ||||
-rw-r--r-- | ext/reflection/php_reflection.c | 2 | ||||
-rw-r--r-- | ext/simplexml/simplexml.c | 52 | ||||
-rw-r--r-- | ext/snmp/snmp.c | 6 | ||||
-rw-r--r-- | ext/xmlreader/php_xmlreader.c | 6 | ||||
-rw-r--r-- | ext/xsl/xsltprocessor.c | 4 | ||||
-rw-r--r-- | ext/zip/php_zip.c | 6 |
15 files changed, 48 insertions, 58 deletions
diff --git a/Zend/zend_iterators.c b/Zend/zend_iterators.c index 8ee376b06c..7a8517edc9 100644 --- a/Zend/zend_iterators.c +++ b/Zend/zend_iterators.c @@ -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, diff --git a/Zend/zend_object_handlers.c b/Zend/zend_object_handlers.c index e8a8a54325..0979206326 100644 --- a/Zend/zend_object_handlers.c +++ b/Zend/zend_object_handlers.c @@ -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 */ diff --git a/Zend/zend_object_handlers.h b/Zend/zend_object_handlers.h index 393322667c..4da62e524f 100644 --- a/Zend/zend_object_handlers.h +++ b/Zend/zend_object_handlers.h @@ -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) diff --git a/Zend/zend_objects_API.c b/Zend/zend_objects_API.c index 3e0baaa691..a2de370b49 100644 --- a/Zend/zend_objects_API.c +++ b/Zend/zend_objects_API.c @@ -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; } diff --git a/Zend/zend_objects_API.h b/Zend/zend_objects_API.h index 5a9e3a5041..2ebaa74360 100644 --- a/Zend/zend_objects_API.h +++ b/Zend/zend_objects_API.h @@ -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) diff --git a/ext/dom/php_dom.c b/ext/dom/php_dom.c index 0d1edd577c..69da603247 100644 --- a/ext/dom/php_dom.c +++ b/ext/dom/php_dom.c @@ -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); } diff --git a/ext/mysqli/mysqli.c b/ext/mysqli/mysqli.c index 56ac64c52a..83e956ebdf 100644 --- a/ext/mysqli/mysqli.c +++ b/ext/mysqli/mysqli.c @@ -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 diff --git a/ext/pdo/pdo_stmt.c b/ext/pdo/pdo_stmt.c index 4f96237675..777736095a 100644 --- a/ext/pdo/pdo_stmt.c +++ b/ext/pdo/pdo_stmt.c @@ -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, diff --git a/ext/pdo/php_pdo_int.h b/ext/pdo/php_pdo_int.h index e09fa22205..a4958fdb3b 100644 --- a/ext/pdo/php_pdo_int.h +++ b/ext/pdo/php_pdo_int.h @@ -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); diff --git a/ext/reflection/php_reflection.c b/ext/reflection/php_reflection.c index 423a37b361..42e4ee3c53 100644 --- a/ext/reflection/php_reflection.c +++ b/ext/reflection/php_reflection.c @@ -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) diff --git a/ext/simplexml/simplexml.c b/ext/simplexml/simplexml.c index 7a5767871d..d7a482a055 100644 --- a/ext/simplexml/simplexml.c +++ b/ext/simplexml/simplexml.c @@ -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; diff --git a/ext/snmp/snmp.c b/ext/snmp/snmp.c index ce1f3ed1e8..59c820a8be 100644 --- a/ext/snmp/snmp.c +++ b/ext/snmp/snmp.c @@ -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; diff --git a/ext/xmlreader/php_xmlreader.c b/ext/xmlreader/php_xmlreader.c index 34b4a17ff8..c91ea2eaa9 100644 --- a/ext/xmlreader/php_xmlreader.c +++ b/ext/xmlreader/php_xmlreader.c @@ -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)); diff --git a/ext/xsl/xsltprocessor.c b/ext/xsl/xsltprocessor.c index b221d11fed..f155bda630 100644 --- a/ext/xsl/xsltprocessor.c +++ b/ext/xsl/xsltprocessor.c @@ -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; diff --git a/ext/zip/php_zip.c b/ext/zip/php_zip.c index 6e19b16480..afb033f130 100644 --- a/ext/zip/php_zip.c +++ b/ext/zip/php_zip.c @@ -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) { |