diff options
| author | Joe Watkins <krakjoe@php.net> | 2019-04-06 01:32:15 +0200 |
|---|---|---|
| committer | Joe Watkins <krakjoe@php.net> | 2019-04-06 01:32:15 +0200 |
| commit | 7b58e43da34b712df3d7a41ccc5e71c2011e74d0 (patch) | |
| tree | c6fca7a02e6b2b6b01500e2b5e3746122349668c | |
| parent | 0ab45c24fe15ff44636afc41d6f50ae7f4ab060c (diff) | |
| parent | 1b85e72032ecf912f6fc50d0704662dfa2cb0292 (diff) | |
| download | php-git-7b58e43da34b712df3d7a41ccc5e71c2011e74d0.tar.gz | |
Merge branch 'PHP-7.4'
* PHP-7.4:
Follow up #77849 PDOStatement objects in undefined state after clone
| -rw-r--r-- | ext/pdo/pdo_stmt.c | 18 | ||||
| -rw-r--r-- | ext/pdo/tests/bug_77849_2.phpt | 18 |
2 files changed, 19 insertions, 17 deletions
diff --git a/ext/pdo/pdo_stmt.c b/ext/pdo/pdo_stmt.c index eb8577bb94..0825cc6771 100644 --- a/ext/pdo/pdo_stmt.c +++ b/ext/pdo/pdo_stmt.c @@ -2243,22 +2243,6 @@ static int dbstmt_compare(zval *object1, zval *object2) return -1; } -static zend_object *dbstmt_clone_obj(zend_object *zobject) -{ - pdo_stmt_t *stmt; - pdo_stmt_t *old_stmt; - - stmt = zend_object_alloc(sizeof(pdo_stmt_t), zobject->ce); - zend_object_std_init(&stmt->std, zobject->ce); - object_properties_init(&stmt->std, zobject->ce); - - old_stmt = php_pdo_stmt_fetch_object(zobject); - - zend_objects_clone_members(&stmt->std, &old_stmt->std); - - return &stmt->std; -} - zend_object_handlers pdo_dbstmt_object_handlers; zend_object_handlers pdo_row_object_handlers; @@ -2712,7 +2696,7 @@ void pdo_stmt_init(void) pdo_dbstmt_object_handlers.unset_property = dbstmt_prop_delete; pdo_dbstmt_object_handlers.get_method = dbstmt_method_get; pdo_dbstmt_object_handlers.compare_objects = dbstmt_compare; - pdo_dbstmt_object_handlers.clone_obj = dbstmt_clone_obj; + pdo_dbstmt_object_handlers.clone_obj = NULL; INIT_CLASS_ENTRY(ce, "PDORow", pdo_row_functions); pdo_row_ce = zend_register_internal_class(&ce); diff --git a/ext/pdo/tests/bug_77849_2.phpt b/ext/pdo/tests/bug_77849_2.phpt new file mode 100644 index 0000000000..53a0735e97 --- /dev/null +++ b/ext/pdo/tests/bug_77849_2.phpt @@ -0,0 +1,18 @@ +--TEST-- +PDO Common: Bug #77849 (inconsistent state of cloned statament object) +--SKIPIF-- +<?php +if (!extension_loaded('pdo')) die('skip'); +?> +--FILE-- +<?php +$stmt = new PDOStatement(); + +clone $stmt; +?> +--EXPECTF-- +Fatal error: Uncaught Error: Trying to clone an uncloneable object of class PDOStatement in %s:4 +Stack trace: +#0 {main} + thrown in %s on line 4 + |
