Browse Source

PHP4: fix object handling

git-svn-id: svn://svn.lighttpd.net/xcache/trunk@1562 c26eb9a1-5813-0410-bd6c-c2e55f420ca7
master
Xuefer 7 years ago
parent
commit
49e586053c
  1. 7
      processor/var-helper.h
  2. 16
      xcache/xc_utils.c

7
processor/var-helper.h

@ -44,7 +44,8 @@ static void xc_var_collect_class(xc_processor_t *processor, zend_class_entry *ce
zend_hash_init(&processor->class_name_to_index, 0, NULL, NULL, 0);
}
next_index = xc_vector_size(&processor->class_names);
/* HashTable <=PHP_4 cannot handle NULL pointers, +1 needed */
next_index = xc_vector_size(&processor->class_names) + 1;
if (zend_hash_add(&processor->class_name_to_index, ce->name, ce->name_length, (void *) &next_index, sizeof(next_index), NULL) == SUCCESS) {
xc_constant_string_t class_name;
class_name.str = (char *) ce->name;
@ -59,10 +60,10 @@ static size_t xc_var_store_ce(xc_processor_t *processor, zend_class_entry *ce TS
if (zend_hash_find(&processor->class_name_to_index, ce->name, ce->name_length, (void **) &index) != SUCCESS) {
php_error_docref(NULL TSRMLS_CC, E_CORE_ERROR, "Internal error: class name not found in class names");
return (size_t) -1;
return (size_t) - 1;
}
return *index;
return *index - 1;
}
/* }}} */
/* on restore */

16
xcache/xc_utils.c

@ -647,13 +647,21 @@ zend_class_entry *xc_lookup_class(const char *class_name, int class_name_len, ze
}
#elif defined(ZEND_ENGINE_2)
if (zend_lookup_class_ex(class_name, class_name_len, autoload, &cest TSRMLS_CC) != SUCCESS) {
return NULL;
cest = NULL;
}
#else
if (zend_hash_find(EG(class_table), class_name, class_name_len, (void **) &cest) != SUCCESS) {
return NULL;
char *lc_class_name;
ALLOCA_FLAG(use_heap);
lc_class_name = xc_do_alloca(sizeof(*class_name) * (class_name_len + 1), use_heap);
strcpy(lc_class_name, class_name);
zend_str_tolower(lc_class_name, class_name_len);
if (zend_hash_find(EG(class_table), lc_class_name, class_name_len + 1, (void **) &cest) != SUCCESS) {
cest = NULL;
}
xc_free_alloca(lc_class_name, use_heap);
#endif
return CestToCePtr(*cest);
return cest ? CestToCePtr(*cest) : NULL;
}
/* }}} */
Loading…
Cancel
Save