]> granicus.if.org Git - php/commitdiff
- Add check for avoid segfault when trying instantiate PDORow manually
authorFelipe Pena <felipe@php.net>
Wed, 14 May 2008 12:28:28 +0000 (12:28 +0000)
committerFelipe Pena <felipe@php.net>
Wed, 14 May 2008 12:28:28 +0000 (12:28 +0000)
ext/pdo/pdo_stmt.c
ext/pdo/tests/pdorow.phpt [new file with mode: 0644]

index 0730b403896b5eda4b131ff2abb914ba294c656e..e6244522a1780309b8f8261b629883ce5e757b95 100755 (executable)
@@ -2714,10 +2714,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 (file)
index 0000000..b33dd15
--- /dev/null
@@ -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