summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ext/pgsql/pgsql.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/ext/pgsql/pgsql.c b/ext/pgsql/pgsql.c
index 4e9755bfea..928abc1233 100644
--- a/ext/pgsql/pgsql.c
+++ b/ext/pgsql/pgsql.c
@@ -117,14 +117,14 @@ static void php_pgsql_set_default_link(int id)
{
PGLS_FETCH();
+ zend_list_addref(id); /* increase refcount for the new default link */
+
if (PGG(default_link) != -1) {
+ /* decrease refcount for the old default link */
zend_list_delete(PGG(default_link));
}
- if (PGG(default_link) != id) {
- PGG(default_link) = id;
- zend_list_addref(id);
- }
+ PGG(default_link) = id;
}