mirror of
https://github.com/php/php-src.git
synced 2025-08-15 21:48:51 +02:00
Fix leak when persistent PDO connection fails
As we don't register the resource, the resource dtor is not called and will not decrement the refcount.
This commit is contained in:
parent
812df2bd8a
commit
c02aa46126
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