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

Move mongoc_client_set_error_api after check for null client pointer

      phongo_manager_init currently has:

      manager->client = php_phongo_make_mongo_client(uri, driverOptions);
      mongoc_client_set_error_api(manager->client, MONGOC_ERROR_API_VERSION_2);
      
      if (!manager->client) {
      	phongo_throw_exception(PHONGO_ERROR_RUNTIME, "Failed to create Manager from URI: '%s'", uri_string);
      	goto cleanup;
      }
      

      In the unlikely event that php_phongo_make_mongo_client returns NULL, mongoc_client_set_error_api could segfault before we throw an exception. In practice, this does not happen because mongoc_client_new_from_uri only returns NULL if SSL is requested but not enabled in libmongoc and we throw for that case earlier; however, this could change if a new error condition is introduced into libmongoc.

            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: