@@ -289,7 +289,7 @@ static void php_pgsql_set_default_link(zend_object *obj)
289289 GC_ADDREF (obj );
290290
291291 if (PGG (default_link ) != NULL ) {
292- GC_DELREF ( obj );
292+ zend_object_release ( PGG ( default_link ) );
293293 }
294294
295295 PGG (default_link ) = obj ;
@@ -409,7 +409,7 @@ static PHP_GINIT_FUNCTION(pgsql)
409409 ZEND_TSRMLS_CACHE_UPDATE ();
410410#endif
411411 memset (pgsql_globals , 0 , sizeof (zend_pgsql_globals ));
412- zend_hash_init (& pgsql_globals -> connections , 0 , NULL , ZVAL_PTR_DTOR , 1 );
412+ zend_hash_init (& pgsql_globals -> connections , 0 , NULL , NULL , 1 );
413413}
414414
415415static void php_libpq_version (char * buf , size_t len )
@@ -595,6 +595,11 @@ PHP_RINIT_FUNCTION(pgsql)
595595
596596PHP_RSHUTDOWN_FUNCTION (pgsql )
597597{
598+ if (PGG (default_link )) {
599+ zend_object_release (PGG (default_link ));
600+ PGG (default_link ) = NULL ;
601+ }
602+
598603 zend_hash_destroy (& PGG (field_oids ));
599604 zend_hash_destroy (& PGG (table_oids ));
600605 /* clean up persistent connection */
@@ -718,7 +723,7 @@ static void php_pgsql_do_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent)
718723 link -> notices = NULL ;
719724 link -> persistent = 1 ;
720725 } else { /* Non persistent connection */
721- zval * index_ptr , new_index_ptr ;
726+ zval * index_ptr ;
722727
723728 /* first we check the hash for the hashed_details key. If it exists,
724729 * it should point us to the right offset where the actual pgsql link sits.
@@ -766,8 +771,7 @@ static void php_pgsql_do_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent)
766771 link -> persistent = 0 ;
767772
768773 /* add it to the hash */
769- ZVAL_COPY (& new_index_ptr , return_value );
770- zend_hash_update (& PGG (connections ), str .s , & new_index_ptr );
774+ zend_hash_update (& PGG (connections ), str .s , return_value );
771775
772776 /* Keep track of link => hash mapping, so we can remove the hash entry from connections
773777 * when the connection is closed. This uses the address of the connection rather than the
0 commit comments