diff --git a/ext/twig/twig.c b/ext/twig/twig.c index 39f4bec40..04cca5fb2 100644 --- a/ext/twig/twig.c +++ b/ext/twig/twig.c @@ -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; }