Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions Zend/zend_object_handlers.h
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,12 @@ typedef zend_object* (*zend_object_clone_obj_with_t)(zend_object *object, const
typedef enum {
ZEND_OBJECT_TRANSFER, /* emalloc → pemalloc (send to another thread) */
ZEND_OBJECT_LOAD, /* pemalloc → emalloc (receive in target thread) */
/* The transit shell is being freed: release what TRANSFER acquired into it.
* The handler frees its own C state and returns NULL; it must not call
* default_fn, and `ctx` may be NULL because a release runs outside a
* request. Without this kind, anything a handler stores in the shell is
* unreachable — free_obj never runs for a shell. */
ZEND_OBJECT_TRANSFER_RELEASE,
} zend_object_transfer_kind_t;

typedef zend_object* (*zend_object_transfer_default_fn)(
Expand Down
12 changes: 12 additions & 0 deletions Zend/zend_weakrefs.c
Original file line number Diff line number Diff line change
Expand Up @@ -818,6 +818,12 @@ static zend_object *zend_weakref_transfer_obj(
{
(void) default_fn;

if (kind == ZEND_OBJECT_TRANSFER_RELEASE) {
/* The transit wrapper owns nothing of its own: the referent slot and the
* class name are freed by the generic release walk. */
return NULL;
}

if (kind == ZEND_OBJECT_TRANSFER) {
zend_weakref *wr = zend_weakref_from(object);
zend_object *referent = wr->referent;
Expand Down Expand Up @@ -875,6 +881,12 @@ static zend_object *zend_weakmap_transfer_obj(
{
(void) default_fn;

if (kind == ZEND_OBJECT_TRANSFER_RELEASE) {
/* The transit wrapper owns nothing of its own: the key/value slots and
* the class name are freed by the generic release walk. */
return NULL;
}

if (kind == ZEND_OBJECT_TRANSFER) {
zend_weakmap *wm = zend_weakmap_from(object);
const uint32_t num = zend_hash_num_elements(&wm->ht);
Expand Down
Loading