-
Type: New Feature
-
Resolution: Done
-
Priority: Critical - P2
-
Affects Version/s: None
-
Component/s: None
-
None
The tests for PHPC-640 include example TypeWrapper implementations for each BSON type, which throw if TypeWrapper::createFromBSONType() receives an unexpected value (e.g. Binary receives a MinKey). This uncovered a segfault on PHP 5.x, as the PHONGO_BSON_TYPE_WRAPPER() blindly assigns the uninitialized return value (zwrapper) to a local variable (zchild). After the macro, zchild is then added to the PHP hash. The macro should instead check if the userland method threw an exception and return early.
This is not necessary in PHP 7, since the return value zval is allocated on the stack, but there is no harm in also checking for an exception and returning early.