Merge branch 'PHP-8.1'

* PHP-8.1:
  Fix leak when persistent PDO connection fails
This commit is contained in:
Nikita Popov 2021-11-16 16:16:34 +01:00
commit a4da60f4b5
2 changed files with 20 additions and 0 deletions

View file

@ -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)) {

View 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