summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAntony Dovgal <tony2001@php.net>2006-03-17 22:17:15 +0000
committerAntony Dovgal <tony2001@php.net>2006-03-17 22:17:15 +0000
commitf5aecbf18cc2e1f57338bd6959ddee4e12e84a77 (patch)
treef5535e22a804b8cc81255a75ded90dd6581838e4
parentfb7324bb71048bb320d2c97c4924aadc5ef3aaa0 (diff)
downloadphp-git-f5aecbf18cc2e1f57338bd6959ddee4e12e84a77.tar.gz
MFB: fix #36727 (segfault in pdo_pgsql bindValue() when no parameters are defined)
-rw-r--r--ext/pdo_pgsql/pgsql_statement.c2
-rw-r--r--ext/pdo_pgsql/tests/bug36727.phpt23
2 files changed, 24 insertions, 1 deletions
diff --git a/ext/pdo_pgsql/pgsql_statement.c b/ext/pdo_pgsql/pgsql_statement.c
index e47388e072..a3f9f908e0 100644
--- a/ext/pdo_pgsql/pgsql_statement.c
+++ b/ext/pdo_pgsql/pgsql_statement.c
@@ -174,7 +174,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