Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:21743 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 15286 invoked by uid 1010); 31 Jan 2006 11:27:37 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 15271 invoked from network); 31 Jan 2006 11:27:37 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 31 Jan 2006 11:27:37 -0000 X-Host-Fingerprint: 216.117.147.250 unknown Linux 2.4/2.6 Received: from ([216.117.147.250:53070] helo=ctindustries.net) by pb1.pair.com (ecelerity 2.0 beta r(6323M)) with SMTP id B5/9A-30290-8A94FD34 for ; Tue, 31 Jan 2006 06:27:37 -0500 Received: from [127.0.0.1] (dsta-aa203.pivot.net [66.186.171.203]) (authenticated bits=0) by ctindustries.net (8.12.8/8.12.8) with ESMTP id k0VAEr3w010969; Tue, 31 Jan 2006 05:14:54 -0500 Message-ID: <43DF4B83.4080302@ctindustries.net> Date: Tue, 31 Jan 2006 06:35:31 -0500 User-Agent: Thunderbird 1.5 (Windows/20051201) MIME-Version: 1.0 To: Andrei Zmievski CC: "internals@lists.php.net" References: <43DA4E9F.8050908@ctindustries.net> <17BE1EF3-68F9-4121-B32F-95B6E2925B03@gravitonic.com> In-Reply-To: <17BE1EF3-68F9-4121-B32F-95B6E2925B03@gravitonic.com> Content-Type: multipart/mixed; boundary="------------030001090008080100090406" X-Antivirus: avast! (VPS 0605-1, 01/30/2006), Outbound message X-Antivirus-Status: Clean X-Virus-Scanned: ClamAV 0.88/1262/Mon Jan 30 15:23:09 2006 on ctindustries.net X-Virus-Status: Clean Subject: Re: [PHP-DEV] crashing due to get_properties handler From: rrichards@ctindustries.net (Rob Richards) --------------030001090008080100090406 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Here's a patch against HEAD for get_object_vars in zend_builtin_functions.c that checks for the return value of the handler. With this change it should at least now be safe to implement the handler and return NULL, as this was the only spot I found in the engine that checked only for the existence of the handler and not the return value. One question I have about this function is why RETURN_FALSE is used when the handler is not implemented or NULL is returned (with patch). I can understand it being returned when used on a non-object, but the function is supposed to return an array, so I would think and empty array should be returned instead. Rob Andrei Zmievski wrote: > I've run into the same thing with PHP-GTK. While Zend engine itself > may check for existence of handler, PHP code does not. > > -Andrei --------------030001090008080100090406 Content-Type: text/plain; name="zend_builtin_functions.c.diff.txt" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="zend_builtin_functions.c.diff.txt" Index: zend_builtin_functions.c =================================================================== RCS file: /repository/ZendEngine2/zend_builtin_functions.c,v retrieving revision 1.300 diff -u -r1.300 zend_builtin_functions.c --- zend_builtin_functions.c 17 Jan 2006 12:18:51 -0000 1.300 +++ zend_builtin_functions.c 31 Jan 2006 11:20:36 -0000 @@ -814,11 +814,16 @@ RETURN_FALSE; } + properties = Z_OBJ_HT_PP(obj)->get_properties(*obj TSRMLS_CC); + + if (properties == NULL) { + RETURN_FALSE; + } + instanceof = EG(This) && instanceof_function(Z_OBJCE_P(EG(This)), Z_OBJCE_PP(obj) TSRMLS_CC); array_init(return_value); - properties = Z_OBJ_HT_PP(obj)->get_properties(*obj TSRMLS_CC); zend_hash_internal_pointer_reset_ex(properties, &pos); while (zend_hash_get_current_data_ex(properties, (void **) &value, &pos) == SUCCESS) { --------------030001090008080100090406--