summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorFelipe Pena <felipe@php.net>2008-05-14 12:34:10 +0000
committerFelipe Pena <felipe@php.net>2008-05-14 12:34:10 +0000
commit908b6e780868aec596e237fd0d21e4d31f515739 (patch)
tree7445c8658148b5e768deef2ad5d02ddb48416072 /ext
parent20eb83c3fe5012ffca5324dee3c3c8198accbfb0 (diff)
downloadphp-git-908b6e780868aec596e237fd0d21e4d31f515739.tar.gz
- MFH: Add check for avoid segfault when trying instantiate PDORow manually
Diffstat (limited to 'ext')
-rwxr-xr-xext/pdo/pdo_stmt.c10
-rw-r--r--ext/pdo/tests/pdorow.phpt10
2 files changed, 16 insertions, 4 deletions
diff --git a/ext/pdo/pdo_stmt.c b/ext/pdo/pdo_stmt.c
index eac65790cf..940fe84567 100755
--- a/ext/pdo/pdo_stmt.c
+++ b/ext/pdo/pdo_stmt.c
@@ -2711,10 +2711,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--
+<?php
+
+new PDORow;
+
+?>
+--EXPECTF--
+Fatal error: PDORow::__construct(): You should not create a PDOStatement manually in %s on line %d