From f6cc283d46a3ea162add0b8586cb62cbbb615c81 Mon Sep 17 00:00:00 2001 From: Felipe Pena Date: Wed, 14 May 2008 12:32:21 +0000 Subject: [PATCH] - MFH: Add check for avoid segfault when trying instantiate PDORow manually --- ext/pdo/pdo_stmt.c | 10 ++++++---- ext/pdo/tests/pdorow.phpt | 10 ++++++++++ 2 files changed, 16 insertions(+), 4 deletions(-) create mode 100644 ext/pdo/tests/pdorow.phpt diff --git a/ext/pdo/pdo_stmt.c b/ext/pdo/pdo_stmt.c index 43656b6f11..d13bf3b420 100755 --- a/ext/pdo/pdo_stmt.c +++ b/ext/pdo/pdo_stmt.c @@ -2715,10 +2715,12 @@ zend_object_handlers pdo_row_object_handlers = { void pdo_row_free_storage(pdo_stmt_t *stmt TSRMLS_DC) { - ZVAL_NULL(&stmt->lazy_object_ref); - - if (--stmt->refcount == 0) { - free_statement(stmt TSRMLS_CC); + if (stmt) { + ZVAL_NULL(&stmt->lazy_object_ref); + + if (--stmt->refcount == 0) { + free_statement(stmt TSRMLS_CC); + } } } diff --git a/ext/pdo/tests/pdorow.phpt b/ext/pdo/tests/pdorow.phpt new file mode 100644 index 0000000000..b33dd155d8 --- /dev/null +++ b/ext/pdo/tests/pdorow.phpt @@ -0,0 +1,10 @@ +--TEST-- +Trying instantiate a PDORow object manually +--FILE-- + +--EXPECTF-- +Fatal error: PDORow::__construct(): You should not create a PDOStatement manually in %s on line %d -- 2.40.0