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
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) {

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to