Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:1522 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 43369 invoked from network); 14 May 2003 20:21:13 -0000 Received: from unknown (HELO mail.3gstech.com) (216.239.132.110) by pb1.pair.com with SMTP; 14 May 2003 20:21:13 -0000 Received: from 3gstech.com (ip12-162-2-41.us01.qualys.com [12.162.2.41]) by mail.3gstech.com (Postfix) with ESMTP id B05509E7B12; Wed, 14 May 2003 13:21:09 -0700 (PDT) Message-ID: <3EC2A508.4010305@3gstech.com> Date: Wed, 14 May 2003 13:20:24 -0700 User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.3) Gecko/20030312 X-Accept-Language: en-us, en MIME-Version: 1.0 To: internals@lists.php.net Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: bug in set_error_handler From: waboring@3gstech.com (walt boring) Howdy, I hope this isn't too late to get in, but I found a problem in set_error_handler() when trying to use an object method as an error handler. I have a patch against php-4.3.1 for Zend/zend_builtin_functions.c set_error_handler was assuming that the value passed in to the function was a string, and hence the test for Z_STRLEN_PP(error_handler) was always 0 if it was called as follows set_error_handler( array(&$this, "myhandler") ); This patch makes sure the type of the var error_handler is a string before testing the length of the name. My question is, why does this block RETURN_TRUE if we set EG(user_error_handler) = NULL; ? shouldn't we return false here? Walt [root@hemna src]# diff -u php-4.3.1/Zend/zend_builtin_functions.c php-4.3.1-walt/Zend/zend_builtin_functions.c --- php-4.3.1/Zend/zend_builtin_functions.c 2002-11-27 12:11:10.000000000 -0800 +++ php-4.3.1-walt/Zend/zend_builtin_functions.c 2003-05-14 13:15:39.000000000 -0700 @@ -891,7 +891,8 @@ } ALLOC_ZVAL(EG(user_error_handler)); - if (Z_STRLEN_PP(error_handler)==0) { /* unset user-defined handler */ + /* Make sure we test for an empty string on a non-array value here */ + if (Z_TYPE_PP(error_handler) == IS_STRING && Z_STRLEN_PP(error_handler)==0) { /* unset user-defined handler */ FREE_ZVAL(EG(user_error_handler)); EG(user_error_handler) = NULL; RETURN_TRUE;