Skip to content

Commit 14c17d9

Browse files
committed
Fixed issue #546 (Segfault due to get_gc handler changed)
1 parent 3e67304 commit 14c17d9

14 files changed

+23
-12
lines changed

‎php_yaf.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,11 @@ extern zend_module_entry yaf_module_entry;
7070
# define GC_ADDREF(gc) (++GC_REFCOUNT(gc))
7171
# define GC_DELREF(gc) (--GC_REFCOUNT(gc))
7272
# endif
73+
# define yaf_fake_get_gc NULL
7374
#else
7475
#define YAF_WRITE_HANDLER zval *
7576
#define YAF_WHANDLER_RET(zv) return zv
77+
HashTable *yaf_fake_get_gc(zend_object *zobj, zval **table, int *n);
7678
#endif
7779

7880
#if PHP_VERSION_ID < 80000

‎routes/yaf_route_map.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ YAF_STARTUP_FUNCTION(route_map) {
372372
memcpy(&yaf_route_map_obj_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
373373
yaf_route_map_obj_handlers.free_obj = yaf_route_map_object_free;
374374
yaf_route_map_obj_handlers.clone_obj = NULL;
375-
yaf_route_map_obj_handlers.get_gc = NULL;
375+
yaf_route_map_obj_handlers.get_gc = yaf_fake_get_gc;
376376
yaf_route_map_obj_handlers.get_properties = yaf_route_map_get_properties;
377377

378378

‎routes/yaf_route_regex.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,7 @@ YAF_STARTUP_FUNCTION(route_regex) {
474474

475475
memcpy(&yaf_route_regex_obj_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
476476
yaf_route_regex_obj_handlers.free_obj = yaf_route_regex_object_free;
477-
yaf_route_regex_obj_handlers.get_gc = NULL;
477+
yaf_route_regex_obj_handlers.get_gc = yaf_fake_get_gc;
478478
yaf_route_regex_obj_handlers.clone_obj = NULL;
479479
yaf_route_regex_obj_handlers.get_properties = yaf_route_regex_get_properties;
480480

‎routes/yaf_route_rewrite.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -499,7 +499,7 @@ YAF_STARTUP_FUNCTION(route_rewrite) {
499499
memcpy(&yaf_route_rewrite_obj_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
500500
yaf_route_rewrite_obj_handlers.free_obj = yaf_route_rewrite_object_free;
501501
yaf_route_rewrite_obj_handlers.clone_obj = NULL;
502-
yaf_route_rewrite_obj_handlers.get_gc = NULL;
502+
yaf_route_rewrite_obj_handlers.get_gc = yaf_fake_get_gc;
503503
yaf_route_rewrite_obj_handlers.get_properties = yaf_route_rewrite_get_properties;
504504

505505
return SUCCESS;

‎routes/yaf_route_simple.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ YAF_STARTUP_FUNCTION(route_simple) {
284284
memcpy(&yaf_route_simple_obj_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
285285
yaf_route_simple_obj_handlers.free_obj = yaf_route_simple_object_free;
286286
yaf_route_simple_obj_handlers.clone_obj = NULL;
287-
yaf_route_simple_obj_handlers.get_gc = NULL;
287+
yaf_route_simple_obj_handlers.get_gc = yaf_fake_get_gc;
288288
yaf_route_simple_obj_handlers.get_properties = yaf_route_simple_get_properties;
289289

290290
return SUCCESS;

‎routes/yaf_route_supervar.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ YAF_STARTUP_FUNCTION(route_supervar) {
245245
memcpy(&yaf_route_supervar_obj_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
246246
yaf_route_supervar_obj_handlers.free_obj = yaf_route_supervar_object_free;
247247
yaf_route_supervar_obj_handlers.clone_obj = NULL;
248-
yaf_route_supervar_obj_handlers.get_gc = NULL;
248+
yaf_route_supervar_obj_handlers.get_gc = yaf_fake_get_gc;
249249
yaf_route_supervar_obj_handlers.get_properties = yaf_route_supervar_get_properties;
250250

251251

‎views/yaf_view_simple.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -685,7 +685,7 @@ YAF_STARTUP_FUNCTION(view_simple) {
685685
yaf_view_simple_obj_handlers.read_property = (zend_object_read_property_t)yaf_view_simple_read_property;
686686
yaf_view_simple_obj_handlers.write_property = (zend_object_write_property_t)yaf_view_simple_write_property;
687687
yaf_view_simple_obj_handlers.clone_obj = NULL;
688-
yaf_view_simple_obj_handlers.get_gc = NULL;
688+
yaf_view_simple_obj_handlers.get_gc = yaf_fake_get_gc;
689689

690690

691691
return SUCCESS;

‎yaf.c‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,15 @@ void yaf_iterator_dtor(zend_object_iterator *iter) /* {{{ */ {
7171
}
7272
/* }}} */
7373

74+
#if PHP_VERSION_ID >= 70400
75+
HashTable *yaf_fake_get_gc(zend_object *zobj, zval **table, int *n) /* {{{ */ {
76+
*n = 0;
77+
*table = NULL;
78+
return NULL;
79+
}
80+
/* }}} */
81+
#endif
82+
7483
static int yaf_iterator_valid(zend_object_iterator *iter) /* {{{ */ {
7584
return zend_hash_has_more_elements_ex(Z_ARRVAL(iter->data), &(((yaf_iterator*)iter)->pos));
7685
}

‎yaf_controller.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -854,7 +854,7 @@ YAF_STARTUP_FUNCTION(controller) {
854854
memcpy(&yaf_controller_obj_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
855855
yaf_controller_obj_handlers.offset = XtOffsetOf(yaf_controller_object, std);
856856
yaf_controller_obj_handlers.clone_obj = NULL;
857-
yaf_controller_obj_handlers.get_gc = NULL;
857+
yaf_controller_obj_handlers.get_gc = yaf_fake_get_gc;
858858
yaf_controller_obj_handlers.free_obj = yaf_controller_object_free;
859859
yaf_controller_obj_handlers.get_properties = yaf_controller_get_properties;
860860
yaf_controller_obj_handlers.read_property = (zend_object_read_property_t)yaf_controller_read_property;

‎yaf_loader.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1000,7 +1000,7 @@ YAF_STARTUP_FUNCTION(loader) {
10001000

10011001
memcpy(&yaf_loader_obj_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
10021002
yaf_loader_obj_handlers.clone_obj = NULL;
1003-
yaf_loader_obj_handlers.get_gc = NULL;
1003+
yaf_loader_obj_handlers.get_gc = yaf_fake_get_gc;
10041004
yaf_loader_obj_handlers.free_obj = yaf_loader_obj_free;
10051005
yaf_loader_obj_handlers.get_properties = yaf_loader_get_properties;
10061006

0 commit comments

Comments
 (0)