@@ -289,7 +289,7 @@ static void php_pgsql_set_default_link(zend_object *obj)
289
289
GC_ADDREF (obj );
290
290
291
291
if (PGG (default_link ) != NULL ) {
292
- GC_DELREF ( obj );
292
+ zend_object_release ( PGG ( default_link ) );
293
293
}
294
294
295
295
PGG (default_link ) = obj ;
@@ -409,7 +409,7 @@ static PHP_GINIT_FUNCTION(pgsql)
409
409
ZEND_TSRMLS_CACHE_UPDATE ();
410
410
#endif
411
411
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 );
413
413
}
414
414
415
415
static void php_libpq_version (char * buf , size_t len )
@@ -595,6 +595,11 @@ PHP_RINIT_FUNCTION(pgsql)
595
595
596
596
PHP_RSHUTDOWN_FUNCTION (pgsql )
597
597
{
598
+ if (PGG (default_link )) {
599
+ zend_object_release (PGG (default_link ));
600
+ PGG (default_link ) = NULL ;
601
+ }
602
+
598
603
zend_hash_destroy (& PGG (field_oids ));
599
604
zend_hash_destroy (& PGG (table_oids ));
600
605
/* clean up persistent connection */
@@ -718,7 +723,7 @@ static void php_pgsql_do_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent)
718
723
link -> notices = NULL ;
719
724
link -> persistent = 1 ;
720
725
} else { /* Non persistent connection */
721
- zval * index_ptr , new_index_ptr ;
726
+ zval * index_ptr ;
722
727
723
728
/* first we check the hash for the hashed_details key. If it exists,
724
729
* 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)
766
771
link -> persistent = 0 ;
767
772
768
773
/* 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 );
771
775
772
776
/* Keep track of link => hash mapping, so we can remove the hash entry from connections
773
777
* when the connection is closed. This uses the address of the connection rather than the
0 commit comments