Skip to content

Commit

Permalink
Fix possible bug with extension dtors being called without the ctors …
Browse files Browse the repository at this point in the history
…being called first
  • Loading branch information
zsuraski committed Apr 29, 2000
1 parent e0a48fe commit 42d1529
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions Zend/zend_compile.h
Expand Up @@ -115,6 +115,7 @@ struct _zend_op_array {
int backpatch_count;
#endif
zend_bool return_reference;
zend_bool done_pass_two;

void *reserved[ZEND_MAX_RESERVED_RESOURCES];
};
Expand Down
6 changes: 5 additions & 1 deletion Zend/zend_opcode.c
Expand Up @@ -98,6 +98,7 @@ void init_op_array(zend_op_array *op_array, int type, int initial_ops_size)
op_array->uses_globals = 0;

op_array->return_reference = 0;
op_array->done_pass_two = 0;

zend_llist_apply_with_argument(&zend_extensions, (void (*)(void *, void *)) zend_extension_op_array_ctor_handler, op_array);
}
Expand Down Expand Up @@ -185,7 +186,9 @@ ZEND_API void destroy_op_array(zend_op_array *op_array)
if (op_array->brk_cont_array) {
efree(op_array->brk_cont_array);
}
zend_llist_apply_with_argument(&zend_extensions, (void (*)(void *, void *)) zend_extension_op_array_dtor_handler, op_array);
if (op_array->done_pass_two) {
zend_llist_apply_with_argument(&zend_extensions, (void (*)(void *, void *)) zend_extension_op_array_dtor_handler, op_array);
}
}


Expand Down Expand Up @@ -300,6 +303,7 @@ int pass_two(zend_op_array *op_array)
if (CG(handle_op_arrays)) {
zend_llist_apply_with_argument(&zend_extensions, (void (*)(void *, void *)) zend_extension_op_array_handler, op_array);
}
op_array->done_pass_two = 1;
return 0;
}

Expand Down

0 comments on commit 42d1529

Please sign in to comment.