]> granicus.if.org Git - php/commitdiff
fix #36727 (segfault in pdo_pgsql bindValue() when no parameters are defined)
authorAntony Dovgal <tony2001@php.net>
Fri, 17 Mar 2006 22:15:57 +0000 (22:15 +0000)
committerAntony Dovgal <tony2001@php.net>
Fri, 17 Mar 2006 22:15:57 +0000 (22:15 +0000)
NEWS
ext/pdo_pgsql/pgsql_statement.c
ext/pdo_pgsql/tests/bug36727.phpt [new file with mode: 0644]

diff --git a/NEWS b/NEWS
index 6451c9744af02be1cb37535716c18e18f24c4904..e14ee271f39e8eca67f7c8b1ea9328e17b676f95 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -9,6 +9,8 @@ PHP                                                                        NEWS
 - Fixed debug_zval_dump() to support private and protected members. (Dmitry)
 - Fixed bug #36743 (In a class extending XMLReader array properties are not 
   writable). (Tony)
+- Fixed bug #36727 (segfault in pdo_pgsql bindValue() when no parameters are 
+  defined). (Tony)
 - Fixed bug #36697 (Transparency is lost when using imagecreatetruecolor).
   (Pierre)
 - Fixed bug #36629 (SoapServer::handle() exits on SOAP faults). (Dmitry)
index df0eb1ec2c57f64272fff57de59b6e495f1b02d4..02418fa14024de61738b9853e9356e768d700080 100644 (file)
@@ -229,7 +229,7 @@ static int pgsql_stmt_param_hook(pdo_stmt_t *stmt, struct pdo_bound_param_data *
                                        } else {
                                                /* resolve parameter name to rewritten name */
                                                char *nameptr;
-                                               if (SUCCESS == zend_hash_find(stmt->bound_param_map,
+                                               if (stmt->bound_param_map && SUCCESS == zend_hash_find(stmt->bound_param_map,
                                                                param->name, param->namelen + 1, (void**)&nameptr)) {
                                                        param->paramno = atoi(nameptr + 1) - 1;
                                                } else {
diff --git a/ext/pdo_pgsql/tests/bug36727.phpt b/ext/pdo_pgsql/tests/bug36727.phpt
new file mode 100644 (file)
index 0000000..c6f7c8a
--- /dev/null
@@ -0,0 +1,23 @@
+--TEST--
+Bug #36727 (segfault in bindValue() when no parameters are defined)
+--SKIPIF--
+<?php
+if (!extension_loaded('pdo') || !extension_loaded('pdo_pgsql')) die('skip not loaded');
+require dirname(__FILE__) . '/../../../ext/pdo/tests/pdo_test.inc';
+require dirname(__FILE__) . '/config.inc';
+PDOTest::skip();
+?>
+--FILE--
+<?php
+require dirname(__FILE__) . '/../../../ext/pdo/tests/pdo_test.inc';
+require dirname(__FILE__) . '/config.inc';
+$db = PDOTest::test_factory(dirname(__FILE__) . '/common.phpt');
+
+$stmt = $db->prepare('SELECT * FROM child');
+var_dump($stmt->bindValue(':test', 1, PDO::PARAM_INT));
+
+echo "Done\n";
+?>
+--EXPECT--
+bool(false)
+Done