Skip to content

Commit 211e6d6

Browse files
committed
Fix GH-21575: Memory leak with notices in pgsql persistent connections.
1 parent 5cd8777 commit 211e6d6

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

ext/pgsql/pgsql.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,12 @@ static void pgsql_link_free(pgsql_link_handle *link)
187187

188188
zend_hash_del(&PGG(connections), link->hash);
189189

190+
if (link->persistent) {
191+
/* Reset the notice processor context to NULL so that notices emitted
192+
* during a subsequent PQreset on this persistent PGconn are safely
193+
* ignored rather than written to a stale link handle. */
194+
PQsetNoticeProcessor(link->conn, _php_pgsql_notice_handler, NULL);
195+
}
190196
link->conn = NULL;
191197
zend_string_release(link->hash);
192198

0 commit comments

Comments
 (0)