# crashing due to get_properties handler

- Thread: https://externals.io/message/21706
- Original archive: https://news-web.php.net/php.internals/21706
- Started by Rob Richards on 2006-01-27T16:47:27+00:00
- Messages: 3
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #21706 — Rob Richards — 2006-01-27T16:47:27+00:00

URL: https://externals.io/message/21706#21706

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

---

## #21730 — Andrei Zmievski — 2006-01-30T05:51:40+00:00

URL: https://externals.io/message/21706#21730 · In reply to: #21706

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




> 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

---

## #21743 — Rob Richards — 2006-01-31T11:35:31+00:00

URL: https://externals.io/message/21706#21743 · In reply to: #21730

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
