summaryrefslogtreecommitdiff
path: root/ext/pdo_sqlite
diff options
context:
space:
mode:
authorXinchen Hui <laruence@php.net>2013-11-05 11:04:55 +0800
committerXinchen Hui <laruence@php.net>2013-11-05 11:04:55 +0800
commite3d9e18e7b24ba2d5c9e420510e804330c94f955 (patch)
tree8acdae615620c1e8e259f7d834e699e273f7b5b2 /ext/pdo_sqlite
parent2b7e89e20a4ab23a50ac2c29884d7d1928560635 (diff)
downloadphp-git-e3d9e18e7b24ba2d5c9e420510e804330c94f955.tar.gz
Fixed Bug #66034 (Segmentation Fault when constructor of PDO statement throws an exception)
I know zend_call_function will initilize retval_ptr_ptr, but still set it to NULL explict is more readable
Diffstat (limited to 'ext/pdo_sqlite')
-rw-r--r--ext/pdo_sqlite/tests/bug66033.phpt33
1 files changed, 33 insertions, 0 deletions
diff --git a/ext/pdo_sqlite/tests/bug66033.phpt b/ext/pdo_sqlite/tests/bug66033.phpt
new file mode 100644
index 0000000000..28da3b54bf
--- /dev/null
+++ b/ext/pdo_sqlite/tests/bug66033.phpt
@@ -0,0 +1,33 @@
+--TEST--
+Bug #66033 (Segmentation Fault when constructor of PDO statement throws an exception)
+--SKIPIF--
+<?php
+if (!extension_loaded('pdo_sqlite')) print 'skip not loaded';
+?>
+--FILE--
+<?php
+class DBStatement extends PDOStatement {
+ public $dbh;
+ protected function __construct($dbh) {
+ $this->dbh = $dbh;
+ throw new Exception("Blah");
+ }
+}
+
+$pdo = new PDO('sqlite::memory:', null, null);
+$pdo->setAttribute(PDO::ATTR_STATEMENT_CLASS, array('DBStatement',
+ array($pdo)));
+$pdo->exec("CREATE TABLE IF NOT EXISTS messages (
+ id INTEGER PRIMARY KEY,
+ title TEXT,
+ message TEXT,
+ time INTEGER)");
+
+try {
+ $pdoStatement = $pdo->query("select * from messages");
+} catch (Exception $e) {
+ var_dump($e->getMessage());
+}
+?>
+--EXPECTF--
+string(4) "Blah"