Uploaded image for project: 'PHP Driver: Extension'
  1. PHP Driver: Extension
  2. PHPC-988

PHP 5.x segfault if TypeWrapper::createFromBSONType() throws exception

    • Type: Icon: New Feature New Feature
    • Resolution: Done
    • Priority: Icon: Critical - P2 Critical - P2
    • 1.3.0-beta1, 1.3.0
    • Affects Version/s: None
    • Component/s: None
    • Labels:
      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.

            Assignee:
            jmikola@mongodb.com Jeremy Mikola
            Reporter:
            jmikola@mongodb.com Jeremy Mikola
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: