Skip to content

Commit

Permalink
MFH: fix #38450 (constructor is not called for classes used in usersp…
Browse files Browse the repository at this point in the history
…ace stream wrappers)
  • Loading branch information
tony2001 committed Aug 14, 2006
1 parent 615a15d commit f42e9f5
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
2 changes: 2 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ PHP NEWS
- Fixed phpinfo() cutoff of variables at \0. (Ilia)
- Fixed a bug in the filter extension that prevented magic_quotes_gpc from
being applied when RAW filter is used. (Ilia)
- Fixed bug #38450 (constructor is not called for classes used in userspace
stream wrappers). (Tony)
- Fixed bug #38438 (DOMNodeList->item(0) segfault on empty NodeList). (Ilia)
- Fixed bug #38431 (xmlrpc_get_type() crashes PHP on objects). (Tony)
- Fixed bug #38424 (Different attribute assignment if new or existing). (Rob)
Expand Down
34 changes: 34 additions & 0 deletions main/streams/userspace.c
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,40 @@ static php_stream *user_wrapper_opener(php_stream_wrapper *wrapper, char *filena
object_init_ex(us->object, uwrap->ce);
ZVAL_REFCOUNT(us->object) = 1;
PZVAL_IS_REF(us->object) = 1;

if (uwrap->ce->constructor) {
zend_fcall_info fci;
zend_fcall_info_cache fcc;
zval *retval_ptr;

fci.size = sizeof(fci);
fci.function_table = &uwrap->ce->function_table;
fci.function_name = NULL;
fci.symbol_table = NULL;
fci.object_pp = &us->object;
fci.retval_ptr_ptr = &retval_ptr;
fci.param_count = 0;
fci.params = NULL;
fci.no_separation = 1;

fcc.initialized = 1;
fcc.function_handler = uwrap->ce->constructor;
fcc.calling_scope = EG(scope);
fcc.object_pp = &us->object;

if (zend_call_function(&fci, &fcc TSRMLS_CC) == FAILURE) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Could not execute %s::%s()", uwrap->ce->name, uwrap->ce->constructor->common.function_name);
zval_dtor(us->object);
FREE_ZVAL(us->object);
efree(us);
FG(user_stream_current_filename) = NULL;
return NULL;
} else {
if (retval_ptr) {
zval_ptr_dtor(&retval_ptr);
}
}
}

if (context) {
MAKE_STD_ZVAL(zcontext);
Expand Down

0 comments on commit f42e9f5

Please sign in to comment.