Skip to content

Commit 1af60a2

Browse files
committed
Keep initialized object_handlers structures in read-only memory.
1 parent 12baec3 commit 1af60a2

File tree

15 files changed

+48
-58
lines changed

15 files changed

+48
-58
lines changed

Zend/zend_iterators.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ static zend_class_entry zend_iterator_class_entry;
2727
static void iter_wrapper_free(zend_object *object);
2828
static void iter_wrapper_dtor(zend_object *object);
2929

30-
static zend_object_handlers iterator_object_handlers = {
30+
static const zend_object_handlers iterator_object_handlers = {
3131
0,
3232
iter_wrapper_free,
3333
iter_wrapper_dtor,

Zend/zend_object_handlers.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1733,7 +1733,7 @@ int zend_std_get_closure(zval *obj, zend_class_entry **ce_ptr, zend_function **f
17331733
}
17341734
/* }}} */
17351735

1736-
ZEND_API zend_object_handlers std_object_handlers = {
1736+
ZEND_API const zend_object_handlers std_object_handlers = {
17371737
0, /* offset */
17381738

17391739
zend_object_std_dtor, /* free_obj */

Zend/zend_object_handlers.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ struct _zend_object_handlers {
165165
};
166166

167167
BEGIN_EXTERN_C()
168-
extern ZEND_API zend_object_handlers std_object_handlers;
168+
extern const ZEND_API zend_object_handlers std_object_handlers;
169169

170170
#define zend_get_function_root_class(fbc) \
171171
((fbc)->common.prototype ? (fbc)->common.prototype->common.scope : (fbc)->common.scope)

Zend/zend_objects_API.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ ZEND_API void ZEND_FASTCALL zend_objects_store_del(zend_object *object) /* {{{ *
197197
}
198198
/* }}} */
199199

200-
ZEND_API zend_object_handlers* ZEND_FASTCALL zend_get_std_object_handlers(void)
200+
ZEND_API const zend_object_handlers* ZEND_FASTCALL zend_get_std_object_handlers(void)
201201
{
202202
return &std_object_handlers;
203203
}

Zend/zend_objects_API.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ static zend_always_inline void zend_object_store_ctor_failed(zend_object *obj)
6767

6868
#define ZEND_OBJECTS_STORE_HANDLERS 0, zend_object_std_dtor, zend_objects_destroy_object, zend_objects_clone_obj
6969

70-
ZEND_API zend_object_handlers * ZEND_FASTCALL zend_get_std_object_handlers(void);
70+
ZEND_API const zend_object_handlers * ZEND_FASTCALL zend_get_std_object_handlers(void);
7171
END_EXTERN_C()
7272

7373
static zend_always_inline void zend_object_release(zend_object *obj)

ext/dom/php_dom.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ static zval *dom_get_property_ptr_ptr(zval *object, zval *member, int type, void
319319
zval *retval = NULL;
320320

321321
if (!obj->prop_handler || !zend_hash_exists(obj->prop_handler, member_str)) {
322-
zend_object_handlers *std_hnd = zend_get_std_object_handlers();
322+
const zend_object_handlers *std_hnd = zend_get_std_object_handlers();
323323
retval = std_hnd->get_property_ptr_ptr(object, member, type, cache_slot);
324324
}
325325

@@ -350,7 +350,7 @@ zval *dom_read_property(zval *object, zval *member, int type, void **cache_slot,
350350
retval = &EG(uninitialized_zval);
351351
}
352352
} else {
353-
zend_object_handlers *std_hnd = zend_get_std_object_handlers();
353+
const zend_object_handlers *std_hnd = zend_get_std_object_handlers();
354354
retval = std_hnd->read_property(object, member, type, cache_slot, rv);
355355
}
356356

@@ -372,7 +372,7 @@ void dom_write_property(zval *object, zval *member, zval *value, void **cache_sl
372372
if (hnd) {
373373
hnd->write_func(obj, value);
374374
} else {
375-
zend_object_handlers *std_hnd = zend_get_std_object_handlers();
375+
const zend_object_handlers *std_hnd = zend_get_std_object_handlers();
376376
std_hnd->write_property(object, member, value, cache_slot);
377377
}
378378

@@ -405,7 +405,7 @@ static int dom_property_exists(zval *object, zval *member, int check_empty, void
405405
zval_dtor(&tmp);
406406
}
407407
} else {
408-
zend_object_handlers *std_hnd = zend_get_std_object_handlers();
408+
const zend_object_handlers *std_hnd = zend_get_std_object_handlers();
409409
retval = std_hnd->has_property(object, member, check_empty, cache_slot);
410410
}
411411

ext/mysqli/mysqli.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ zval *mysqli_read_property(zval *object, zval *member, int type, void **cache_sl
321321
retval = &EG(uninitialized_zval);
322322
}
323323
} else {
324-
zend_object_handlers *std_hnd = zend_get_std_object_handlers();
324+
const zend_object_handlers *std_hnd = zend_get_std_object_handlers();
325325
retval = std_hnd->read_property(object, member, type, cache_slot, rv);
326326
}
327327

@@ -354,7 +354,7 @@ void mysqli_write_property(zval *object, zval *member, zval *value, void **cache
354354
if (hnd) {
355355
hnd->write_func(obj, value);
356356
} else {
357-
zend_object_handlers *std_hnd = zend_get_std_object_handlers();
357+
const zend_object_handlers *std_hnd = zend_get_std_object_handlers();
358358
std_hnd->write_property(object, member, value, cache_slot);
359359
}
360360

@@ -409,7 +409,7 @@ static int mysqli_object_has_property(zval *object, zval *member, int has_set_ex
409409
php_error_docref(NULL, E_WARNING, "Invalid value for has_set_exists");
410410
}
411411
} else {
412-
zend_object_handlers *std_hnd = zend_get_std_object_handlers();
412+
const zend_object_handlers *std_hnd = zend_get_std_object_handlers();
413413
ret = std_hnd->has_property(object, member, has_set_exists, cache_slot);
414414
}
415415

@@ -561,7 +561,7 @@ static PHP_GINIT_FUNCTION(mysqli)
561561
PHP_MINIT_FUNCTION(mysqli)
562562
{
563563
zend_class_entry *ce,cex;
564-
zend_object_handlers *std_hnd = zend_get_std_object_handlers();
564+
const zend_object_handlers *std_hnd = zend_get_std_object_handlers();
565565

566566
REGISTER_INI_ENTRIES();
567567
#ifndef MYSQLI_USE_MYSQLND

ext/pdo/pdo_stmt.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2668,7 +2668,7 @@ static int row_compare(zval *object1, zval *object2)
26682668
return -1;
26692669
}
26702670

2671-
zend_object_handlers pdo_row_object_handlers = {
2671+
const zend_object_handlers pdo_row_object_handlers = {
26722672
0,
26732673
zend_objects_destroy_object,
26742674
pdo_row_free_storage,

ext/pdo/php_pdo_int.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ extern zend_object *pdo_row_new(zend_class_entry *ce);
5151
extern const zend_function_entry pdo_row_functions[];
5252
extern zend_class_entry *pdo_row_ce;
5353
void pdo_row_free_storage(zend_object *std);
54-
extern zend_object_handlers pdo_row_object_handlers;
54+
extern const zend_object_handlers pdo_row_object_handlers;
5555

5656
zend_object_iterator *php_pdo_dbstmt_iter_get(zend_class_entry *ce, zval *object);
5757

ext/reflection/php_reflection.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6694,7 +6694,7 @@ static const zend_function_entry reflection_ext_functions[] = { /* {{{ */
66946694
PHP_FE_END
66956695
}; /* }}} */
66966696

6697-
static zend_object_handlers *zend_std_obj_handlers;
6697+
static const zend_object_handlers *zend_std_obj_handlers;
66986698

66996699
/* {{{ _reflection_write_property */
67006700
static void _reflection_write_property(zval *object, zval *member, zval *value, void **cache_slot)

0 commit comments

Comments
 (0)