mirror of
https://github.com/php/php-src.git
synced 2026-03-27 17:52:16 +01:00
MFB: fix #36727 (segfault in pdo_pgsql bindValue() when no parameters are defined)
This commit is contained in:
@@ -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 {
|
||||
|
||||
23
ext/pdo_pgsql/tests/bug36727.phpt
Normal file
23
ext/pdo_pgsql/tests/bug36727.phpt
Normal file
@@ -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
|
||||
Reference in New Issue
Block a user