} else {
fcc->called_scope = EG(called_scope);
fcc->calling_scope = EG(scope);
- if (!fcc->object_ptr) {
+ if (!fcc->object_ptr && Z_TYPE(EG(This)) == IS_OBJECT) {
fcc->object_ptr = &EG(This);
}
ret = 1;
}
} else if (name_len == sizeof("parent") - 1 &&
- !memcmp(lcname, "parent", sizeof("parent") - 1)) {
+ !memcmp(lcname->val, "parent", sizeof("parent") - 1)) {
if (!EG(scope)) {
if (error) *error = estrdup("cannot access parent:: when no class scope is active");
} else if (!EG(scope)->parent) {
} else {
fcc->called_scope = EG(called_scope);
fcc->calling_scope = EG(scope)->parent;
- if (!fcc->object_ptr) {
+ if (!fcc->object_ptr && Z_TYPE(EG(This)) == IS_OBJECT) {
fcc->object_ptr = &EG(This);
}
*strict_class = 1;
ret = 1;
}
} else if (name_len == sizeof("static") - 1 &&
- !memcmp(lcname, "static", sizeof("static") - 1)) {
+ !memcmp(lcname->val, "static", sizeof("static") - 1)) {
if (!EG(called_scope)) {
if (error) *error = estrdup("cannot access static:: when no class scope is active");
} else {
fcc->called_scope = EG(called_scope);
fcc->calling_scope = EG(called_scope);
- if (!fcc->object_ptr) {
+ if (!fcc->object_ptr && Z_TYPE(EG(This)) == IS_OBJECT) {
fcc->object_ptr = &EG(This);
}
*strict_class = 1;
} else {
if (error) zend_spprintf(error, 0, "class '%.*s' not found", name_len, name->val);
}
- efree(lcname);
+ STR_FREE(lcname);
return ret;
}
/* }}} */
{
zend_class_entry *ce_org = fcc->calling_scope;
int retval = 0;
- zend_string *mname;
+ zend_string *mname, *cname;
zend_string *lmname;
const char *colon;
int clen, mlen;
EG(scope) = ce_org;
}
- if (!zend_is_callable_check_class(Z_STR_P(callable), fcc, &strict_class, error TSRMLS_CC)) {
+ cname = STR_INIT(Z_STRVAL_P(callable), clen, 0);
+ if (!zend_is_callable_check_class(cname, fcc, &strict_class, error TSRMLS_CC)) {
+ STR_RELEASE(cname);
EG(scope) = last_scope;
return 0;
}
+ STR_RELEASE(cname);
EG(scope) = last_scope;
ftable = &fcc->calling_scope->function_table;
}
} else if (error && !(check_flags & IS_CALLABLE_CHECK_SILENT)) {
if (fcc->calling_scope) {
- if (error) zend_spprintf(error, 0, "class '%s' does not have a method '%s'", fcc->calling_scope->name, mname);
+ if (error) zend_spprintf(error, 0, "class '%s' does not have a method '%s'", fcc->calling_scope->name->val, mname->val);
} else {
- if (error) zend_spprintf(error, 0, "function '%s' does not exist", mname);
+ if (error) zend_spprintf(error, 0, "function '%s' does not exist", mname->val);
}
}
- efree(lmname);
+ STR_FREE(lmname);
+ STR_RELEASE(mname);
if (fcc->object_ptr) {
fcc->called_scope = Z_OBJCE_P(fcc->object_ptr);
if (parent_ce->default_static_members_count) {
int i = ce->default_static_members_count + parent_ce->default_static_members_count;
- ce->default_static_members_table = erealloc(ce->default_static_members_table, sizeof(void*) * i);
+ ce->default_static_members_table = erealloc(ce->default_static_members_table, sizeof(zval) * i);
if (ce->default_static_members_count) {
while (i-- > parent_ce->default_static_members_count) {
ce->default_static_members_table[i] = ce->default_static_members_table[i - parent_ce->default_static_members_count];
if (parent_ce->default_static_members_count) {
int i = ce->default_static_members_count + parent_ce->default_static_members_count;
- ce->default_static_members_table = perealloc(ce->default_static_members_table, sizeof(void*) * i, ce->type == ZEND_INTERNAL_CLASS);
+ ce->default_static_members_table = perealloc(ce->default_static_members_table, sizeof(zval) * i, ce->type == ZEND_INTERNAL_CLASS);
if (ce->default_static_members_count) {
while (i-- > parent_ce->default_static_members_count) {
ce->default_static_members_table[i] = ce->default_static_members_table[i - parent_ce->default_static_members_count];
void zend_do_declare_class_constant(znode *var_name, const znode *value TSRMLS_DC) /* {{{ */
{
zval property;
- zend_string *cname = NULL;
if(Z_TYPE(value->u.constant) == IS_CONSTANT_ARRAY) {
zend_error_noreturn(E_COMPILE_ERROR, "Arrays are not allowed in class constants");
ZVAL_COPY_VALUE(&property, &value->u.constant);
- cname = zend_new_interned_string(Z_STR(var_name->u.constant) TSRMLS_CC);
- if (zend_hash_add(&CG(active_class_entry)->constants_table, cname, &property) == NULL) {
+ Z_STR(var_name->u.constant) = zend_new_interned_string(Z_STR(var_name->u.constant) TSRMLS_CC);
+ if (zend_hash_add(&CG(active_class_entry)->constants_table, Z_STR(var_name->u.constant), &property) == NULL) {
zend_error_noreturn(E_COMPILE_ERROR, "Cannot redefine class constant %s::%s", CG(active_class_entry)->name->val, Z_STRVAL(var_name->u.constant));
}
FREE_PNODE(var_name);