merged branch arnaud-lb/ext-crash (PR #558)

Commits
-------

c920344 code style
50da1a2 don't modify function name

Discussion
----------

Fix crash in extension

This fixes a crash caused by `php_strtolower()` modifying its input. (Crashes on amd64, but not on x86 for me.)
This commit is contained in:
Fabien Potencier
2011-12-11 16:53:52 +01:00
+8 -4
View File
@@ -620,16 +620,20 @@ static int twig_add_method_to_class(void *pDest TSRMLS_DC, int num_args, va_list
{
zval *retval;
char *item;
size_t item_len;
zend_function *mptr = (zend_function *) pDest;
if ( ! (mptr->common.fn_flags & ZEND_ACC_PUBLIC ) ) {
if (!(mptr->common.fn_flags & ZEND_ACC_PUBLIC)) {
return 0;
}
retval = va_arg(args, zval*);
item = php_strtolower(mptr->common.function_name, strlen(mptr->common.function_name));
add_assoc_string(retval, item, item, 1);
item_len = strlen(mptr->common.function_name);
item = estrndup(mptr->common.function_name, item_len);
php_strtolower(item, item_len);
add_assoc_stringl_ex(retval, item, item_len+1, item, item_len, 0);
return 0;
}
@@ -641,7 +645,7 @@ static int twig_add_property_to_class(void *pDest TSRMLS_DC, int num_args, va_li
char *class_name, *prop_name;
zend_property_info *pptr = (zend_property_info *) pDest;
if ( ! (pptr->flags & ZEND_ACC_PUBLIC ) ) {
if (!(pptr->flags & ZEND_ACC_PUBLIC)) {
return 0;
}