Skip to content

Commit 0d5be6c

Browse files
committed
Merge branch 'PHP-7.2' into PHP-7.3
* PHP-7.2: Fix bug #77849 Disable cloning of PDO handle/connection objects to avoid segfault
2 parents 31fe6cf + 9ec1525 commit 0d5be6c

File tree

3 files changed

+28
-0
lines changed

3 files changed

+28
-0
lines changed

NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ PHP NEWS
2121
- PCRE:
2222
. Fixed bug #77827 (preg_match does not ignore \r in regex flags). (requinix,
2323
cmb)
24+
25+
- PDO:
26+
. Fixed bug #77849 (Disable cloning of PDO handle/connection objects).
27+
(camporter)
2428

2529
- phpdbg:
2630
. Fixed bug #76801 (too many open files). (alekitto)

ext/pdo/pdo_dbh.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1390,6 +1390,7 @@ void pdo_dbh_init(void)
13901390
pdo_dbh_object_handlers.offset = XtOffsetOf(pdo_dbh_object_t, std);
13911391
pdo_dbh_object_handlers.dtor_obj = zend_objects_destroy_object;
13921392
pdo_dbh_object_handlers.free_obj = pdo_dbh_free_storage;
1393+
pdo_dbh_object_handlers.clone_obj = NULL;
13931394
pdo_dbh_object_handlers.get_method = dbh_method_get;
13941395
pdo_dbh_object_handlers.compare_objects = dbh_compare;
13951396
pdo_dbh_object_handlers.get_gc = dbh_get_gc;

ext/pdo/tests/bug_77849.phpt

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
--TEST--
2+
PDO Common: Bug #77849 (Unexpected segfault attempting to use cloned PDO object)
3+
--SKIPIF--
4+
<?php
5+
if (!extension_loaded('pdo')) die('skip');
6+
$dir = getenv('REDIR_TEST_DIR');
7+
if (false == $dir) die('skip no driver');
8+
require_once $dir . 'pdo_test.inc';
9+
PDOTest::skip();
10+
?>
11+
--FILE--
12+
<?php
13+
if (getenv('REDIR_TEST_DIR') === false) putenv('REDIR_TEST_DIR='.dirname(__FILE__) . '/../../pdo/tests/');
14+
require_once getenv('REDIR_TEST_DIR') . 'pdo_test.inc';
15+
16+
$db = PDOTest::factory();
17+
$db2 = clone $db;
18+
?>
19+
--EXPECTF--
20+
Fatal error: Uncaught Error: Trying to clone an uncloneable object of class PDO in %s
21+
Stack trace:
22+
#0 {main}
23+
thrown in %s on line %d

0 commit comments

Comments
 (0)