summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--NEWS2
-rw-r--r--ext/pdo_pgsql/pgsql_statement.c2
-rw-r--r--ext/pdo_pgsql/tests/bug36727.phpt23
3 files changed, 26 insertions, 1 deletions
diff --git a/NEWS b/NEWS
index 6451c9744a..e14ee271f3 100644
--- 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)
diff --git a/ext/pdo_pgsql/pgsql_statement.c b/ext/pdo_pgsql/pgsql_statement.c
index df0eb1ec2c..02418fa140 100644
--- a/ext/pdo_pgsql/pgsql_statement.c
+++ b/ext/pdo_pgsql/pgsql_statement.c
@@ -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
index 0000000000..c6f7c8a80f
--- /dev/null
+++ b/ext/pdo_pgsql/tests/bug36727.phpt
@@ -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