mirror of
https://github.com/php/php-src.git
synced 2025-08-16 05:58:45 +02:00
Merge branch 'PHP-8.1'
* PHP-8.1: Fix leak when persistent PDO connection fails
This commit is contained in:
commit
a4da60f4b5
2 changed files with 20 additions and 0 deletions
|
@ -419,6 +419,10 @@ options:
|
|||
}
|
||||
|
||||
/* the connection failed; things will tidy up in free_storage */
|
||||
if (is_persistent) {
|
||||
dbh->refcount--;
|
||||
}
|
||||
|
||||
/* XXX raise exception */
|
||||
zend_restore_error_handling(&zeh);
|
||||
if (!EG(exception)) {
|
||||
|
|
16
ext/pdo_mysql/tests/construct_persistent_failure.phpt
Normal file
16
ext/pdo_mysql/tests/construct_persistent_failure.phpt
Normal file
|
@ -0,0 +1,16 @@
|
|||
--TEST--
|
||||
Failure when creating persistent connection
|
||||
--EXTENSIONS--
|
||||
pdo_mysql
|
||||
--FILE--
|
||||
<?php
|
||||
try {
|
||||
$pdo = new PDO('mysql:host=localhost', 'invalid_user', 'invalid_password', [
|
||||
PDO::ATTR_PERSISTENT => true,
|
||||
]);
|
||||
} catch (PDOException $e) {
|
||||
echo "Caught\n";
|
||||
}
|
||||
?>
|
||||
--EXPECT--
|
||||
Caught
|
Loading…
Add table
Add a link
Reference in a new issue