mirror of
https://github.com/php/php-src.git
synced 2025-08-18 23:18:56 +02:00
Fix pgsql use after free trying to reuse closed connection
When a connection is closed, we also need to remove the hash entry from the regular_list, as it now points to freed memory. To do this store a reverse mapping from the connection to the hash string. It would be nicer to introduce a wrapping structure for the pgsql link resource that could store the hash (and notices), but that would require large changes to the extension, so I'm going for a more minimal fix here.
This commit is contained in:
parent
b55715d61a
commit
c7a86a38a3
4 changed files with 47 additions and 9 deletions
19
ext/pgsql/tests/connect_after_close.phpt
Normal file
19
ext/pgsql/tests/connect_after_close.phpt
Normal file
|
@ -0,0 +1,19 @@
|
|||
--TEST--
|
||||
Reopen connection after it was closed
|
||||
--SKIPIF--
|
||||
<?php include("skipif.inc"); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
include('config.inc');
|
||||
|
||||
/* Run me under valgrind */
|
||||
$db1 = pg_connect($conn_str);
|
||||
unset($db1);
|
||||
var_dump(pg_close());
|
||||
$db2 = pg_connect($conn_str);
|
||||
unset($db2);
|
||||
var_dump(pg_close());
|
||||
?>
|
||||
--EXPECT--
|
||||
bool(true)
|
||||
bool(true)
|
Loading…
Add table
Add a link
Reference in a new issue