@@ -2548,7 +2548,7 @@ static char* php_phongo_manager_make_client_hash(const char* uri_string, zval* o
25482548
25492549 if (!EG (exception )) {
25502550 * hash_len = ZSTR_LEN (var_buf .s );
2551- hash = pestrndup (ZSTR_VAL (var_buf .s ), * hash_len , 1 );
2551+ hash = estrndup (ZSTR_VAL (var_buf .s ), * hash_len );
25522552 }
25532553
25542554 zval_ptr_dtor (& args );
@@ -2580,7 +2580,7 @@ static char* php_phongo_manager_make_client_hash(const char* uri_string, zval* o
25802580
25812581 if (!EG (exception )) {
25822582 * hash_len = var_buf .len ;
2583- hash = pestrndup (var_buf .c , * hash_len , 1 );
2583+ hash = estrndup (var_buf .c , * hash_len );
25842584 }
25852585
25862586 zval_ptr_dtor (& args );
@@ -2655,21 +2655,19 @@ static mongoc_client_t* php_phongo_find_client(const char* hash, size_t hash_len
26552655
26562656void phongo_manager_init (php_phongo_manager_t * manager , const char * uri_string , zval * options , zval * driverOptions TSRMLS_DC ) /* {{{ */
26572657{
2658- char * hash = NULL ;
2659- size_t hash_len = 0 ;
26602658 bson_t bson_options = BSON_INITIALIZER ;
26612659 mongoc_uri_t * uri = NULL ;
26622660#ifdef MONGOC_ENABLE_SSL
26632661 mongoc_ssl_opt_t * ssl_opt = NULL ;
26642662#endif
26652663
2666- if (!(hash = php_phongo_manager_make_client_hash (uri_string , options , driverOptions , & hash_len TSRMLS_CC ))) {
2664+ if (!(manager -> client_hash = php_phongo_manager_make_client_hash (uri_string , options , driverOptions , & manager -> client_hash_len TSRMLS_CC ))) {
26672665 /* Exception should already have been thrown and there is nothing to free */
26682666 return ;
26692667 }
26702668
2671- if ((manager -> client = php_phongo_find_client (hash , hash_len TSRMLS_CC ))) {
2672- MONGOC_DEBUG ("Found client for hash: %s\n" , hash );
2669+ if ((manager -> client = php_phongo_find_client (manager -> client_hash , manager -> client_hash_len TSRMLS_CC ))) {
2670+ MONGOC_DEBUG ("Found client for hash: %s\n" , manager -> client_hash );
26732671 goto cleanup ;
26742672 }
26752673
@@ -2733,14 +2731,10 @@ void phongo_manager_init(php_phongo_manager_t* manager, const char* uri_string,
27332731 }
27342732#endif
27352733
2736- MONGOC_DEBUG ("Created client hash: %s\n" , hash );
2737- php_phongo_persist_client (hash , hash_len , manager -> client TSRMLS_CC );
2734+ MONGOC_DEBUG ("Created client hash: %s\n" , manager -> client_hash );
2735+ php_phongo_persist_client (manager -> client_hash , manager -> client_hash_len , manager -> client TSRMLS_CC );
27382736
27392737cleanup :
2740- if (hash ) {
2741- pefree (hash , 1 );
2742- }
2743-
27442738 bson_destroy (& bson_options );
27452739
27462740 if (uri ) {
0 commit comments