summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXuefer <xuefer@gmail.com>2014-11-10 13:24:52 +0000
committerXuefer <xuefer@gmail.com>2014-11-10 13:24:52 +0000
commit49e586053c40eb367f90a464818111df867c0625 (patch)
tree2cc793a1e1ef851ab9b95689e7195ee69815c5e7
parent51accff949c03c54a1f5fef4c54e2aa61feb00ba (diff)
downloadxcache-49e586053c40eb367f90a464818111df867c0625.tar.gz
xcache-49e586053c40eb367f90a464818111df867c0625.zip
PHP4: fix object handling
git-svn-id: svn://svn.lighttpd.net/xcache/trunk@1562 c26eb9a1-5813-0410-bd6c-c2e55f420ca7
-rw-r--r--processor/var-helper.h7
-rw-r--r--xcache/xc_utils.c16
2 files changed, 16 insertions, 7 deletions
diff --git a/processor/var-helper.h b/processor/var-helper.h
index 700dfb4..92feb22 100644
--- a/processor/var-helper.h
+++ b/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 */
diff --git a/xcache/xc_utils.c b/xcache/xc_utils.c
index 244d015..48db730 100644
--- a/xcache/xc_utils.c
+++ b/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;
}
/* }}} */