crashing due to get_properties handler

php.internals

Rob Richards

20 years ago
Is it required that the get_properties handler be implemented for an object? In the source there are places that it tests if it is implemented and then tests the returned value in the event it is NULL. The problem is that this is not consistent throughout the zend and php source and I'm getting crashes on certain calls. For example: calling var_dump in var.c: Z_OBJPROP_PP is used without testing if implemented so the handler is required otherwise crash. get_object_vars in zend_builtin_functions.c: checks to see if it is implemented, but doesn't test the return value in the case of NULL. I assume checks for both the handler existing and the return value possibly being NULL are what should be used throughout the code, but wanted to check on that first. Rob

Andrei Zmievski

20 years ago
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 On Jan 27, 2006, at 8:47 AM, Rob Richards wrote:

Rob Richards

20 years ago
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: