Skip to content

Commit

Permalink
Fix bug #77849 Disable cloning of PDO handle/connection objects to av…
Browse files Browse the repository at this point in the history
…oid segfault
  • Loading branch information
camporter authored and krakjoe committed Apr 5, 2019
1 parent 7b0ed89 commit 9ec1525
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 0 deletions.
4 changes: 4 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ PHP NEWS
. Fixed bug #77827 (preg_match does not ignore \r in regex flags). (requinix,
cmb)

- PDO:
. Fixed bug #77849 (Disable cloning of PDO handle/connection objects).
(camporter)

- phpdbg:
. Fixed bug #76801 (too many open files). (alekitto)
. Fixed bug #77800 (phpdbg segfaults on listing some conditional breakpoints).
Expand Down
1 change: 1 addition & 0 deletions ext/pdo/pdo_dbh.c
Original file line number Diff line number Diff line change
Expand Up @@ -1403,6 +1403,7 @@ void pdo_dbh_init(void)
pdo_dbh_object_handlers.offset = XtOffsetOf(pdo_dbh_object_t, std);
pdo_dbh_object_handlers.dtor_obj = zend_objects_destroy_object;
pdo_dbh_object_handlers.free_obj = pdo_dbh_free_storage;
pdo_dbh_object_handlers.clone_obj = NULL;
pdo_dbh_object_handlers.get_method = dbh_method_get;
pdo_dbh_object_handlers.compare_objects = dbh_compare;
pdo_dbh_object_handlers.get_gc = dbh_get_gc;
Expand Down
23 changes: 23 additions & 0 deletions ext/pdo/tests/bug_77849.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
--TEST--
PDO Common: Bug #77849 (Unexpected segfault attempting to use cloned PDO object)
--SKIPIF--
<?php
if (!extension_loaded('pdo')) die('skip');
$dir = getenv('REDIR_TEST_DIR');
if (false == $dir) die('skip no driver');
require_once $dir . 'pdo_test.inc';
PDOTest::skip();
?>
--FILE--
<?php
if (getenv('REDIR_TEST_DIR') === false) putenv('REDIR_TEST_DIR='.dirname(__FILE__) . '/../../pdo/tests/');
require_once getenv('REDIR_TEST_DIR') . 'pdo_test.inc';

$db = PDOTest::factory();
$db2 = clone $db;
?>
--EXPECTF--
Fatal error: Uncaught Error: Trying to clone an uncloneable object of class PDO in %s
Stack trace:
#0 {main}
thrown in %s on line %d

0 comments on commit 9ec1525

Please sign in to comment.