]> granicus.if.org Git - php/commitdiff
MFH: fix leak appearing when calling non-static protected or private methods as static
authorAntony Dovgal <tony2001@php.net>
Sat, 2 Feb 2008 22:29:41 +0000 (22:29 +0000)
committerAntony Dovgal <tony2001@php.net>
Sat, 2 Feb 2008 22:29:41 +0000 (22:29 +0000)
Zend/zend_API.c

index fe921a0ddcdc644d2b5300bc99c369e9534da8b2..05ab18d5f5589c4a56d48c73a9a7f224c84f42c3 100644 (file)
@@ -2314,6 +2314,10 @@ static int zend_is_callable_check_func(int check_flags, zval ***zobj_ptr_ptr, ze
        zend_function *fptr;
        HashTable *ftable;
 
+       if (error) {
+               *error = NULL;
+       }
+
        *ce_ptr = NULL;
        *fptr_ptr = NULL;
 
@@ -2431,12 +2435,22 @@ static int zend_is_callable_check_func(int check_flags, zval ***zobj_ptr_ptr, ze
                        if (retval && (check_flags & IS_CALLABLE_CHECK_NO_ACCESS) == 0) {
                                if (fptr->op_array.fn_flags & ZEND_ACC_PRIVATE) {
                                        if (!zend_check_private(fptr, *zobj_ptr_ptr ? Z_OBJCE_PP(*zobj_ptr_ptr) : EG(scope), lmname, mlen TSRMLS_CC)) {
-                                               if (error) zend_spprintf(error, 0, "cannot access private method %s::%s()", (*ce_ptr)->name, fptr->common.function_name);
+                                               if (error) {
+                                                       if (*error) {
+                                                               efree(*error);
+                                                       }
+                                                       zend_spprintf(error, 0, "cannot access private method %s::%s()", (*ce_ptr)->name, fptr->common.function_name);
+                                               }
                                                retval = 0;
                                        }
                                } else if ((fptr->common.fn_flags & ZEND_ACC_PROTECTED)) {
                                        if (!zend_check_protected(fptr->common.scope, EG(scope))) {
-                                               if (error) zend_spprintf(error, 0, "cannot access protected method %s::%s()", (*ce_ptr)->name, fptr->common.function_name);
+                                               if (error) {
+                                                       if (*error) {
+                                                               efree(*error);
+                                                       }
+                                                       zend_spprintf(error, 0, "cannot access protected method %s::%s()", (*ce_ptr)->name, fptr->common.function_name);
+                                               }
                                                retval = 0;
                                        }
                                }