Skip to content

Commit f194cdf

Browse files
committed
ext/pgsql: fix PGtrace invalid free issue.
disable trace when closing the connection, is a no op if there is no stream attached to it. Close phpGH-11403
1 parent 7eb3e9c commit f194cdf

File tree

3 files changed

+24
-0
lines changed

3 files changed

+24
-0
lines changed

NEWS

+3
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ PHP NEWS
5151
. Fixed bug GH-9356 Incomplete validation of IPv6 Address fields in
5252
subjectAltNames (James Lucas, Jakub Zelenka).
5353

54+
- PGSQL:
55+
. Fixed intermittent segfault with pg_trace. (David Carlier)
56+
5457
- Phar:
5558
. Fix cross-compilation check in phar generation for FreeBSD. (peter279k)
5659

ext/pgsql/pgsql.c

+1
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ static void pgsql_link_free(pgsql_link_handle *link)
172172
PQclear(res);
173173
}
174174
if (!link->persistent) {
175+
PQuntrace(link->conn);
175176
PQfinish(link->conn);
176177
}
177178
PGG(num_links)--;

ext/pgsql/tests/pg_trace.phpt

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
--TEST--
2+
pg_trace
3+
--EXTENSIONS--
4+
pgsql
5+
--SKIPIF--
6+
<?php include("skipif.inc"); ?>
7+
--FILE--
8+
<?php
9+
10+
include('config.inc');
11+
12+
$db = pg_connect($conn_str);
13+
$tracefile = __DIR__ . '/trace.tmp';
14+
15+
var_dump(pg_trace($tracefile, 'w', $db));
16+
$res = pg_query($db, 'select 1');
17+
18+
?>
19+
--EXPECTF--
20+
bool(true)

0 commit comments

Comments
 (0)