diff --git a/NEWS b/NEWS index df5c45f246f..64c4ee19eff 100644 --- a/NEWS +++ b/NEWS @@ -65,6 +65,9 @@ PHP NEWS (nielsdos) . Fixed bug GH-18112 (NULL access with preloading and INI option). (nielsdos) +- PDO: + . Fix memory leak when destroying PDORow. (nielsdos) + - Standard: . Fix memory leaks in array_any() / array_all(). (nielsdos) diff --git a/ext/pdo/pdo_stmt.c b/ext/pdo/pdo_stmt.c index fce9901ab82..006e49461f6 100644 --- a/ext/pdo/pdo_stmt.c +++ b/ext/pdo/pdo_stmt.c @@ -2502,6 +2502,7 @@ void pdo_row_free_storage(zend_object *std) ZVAL_UNDEF(&row->stmt->lazy_object_ref); OBJ_RELEASE(&row->stmt->std); } + zend_object_std_dtor(std); } zend_object *pdo_row_new(zend_class_entry *ce) diff --git a/ext/pdo_sqlite/tests/gh18114.phpt b/ext/pdo_sqlite/tests/gh18114.phpt new file mode 100644 index 00000000000..85055884548 --- /dev/null +++ b/ext/pdo_sqlite/tests/gh18114.phpt @@ -0,0 +1,19 @@ +--TEST-- +GH-18114 (pdo lazy object crash) +--EXTENSIONS-- +pdo_sqlite +--FILE-- +query('select 1 as queryString'); +$data = $x->fetch(PDO::FETCH_LAZY); +foreach ($data as $entry) { + var_dump($entry); +} +var_dump((array) $data); +echo "Done\n"; +?> +--EXPECT-- +array(0) { +} +Done