summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatteo Beccati <mbeccati@php.net>2016-07-10 14:38:17 +0200
committerMatteo Beccati <mbeccati@php.net>2016-07-10 14:38:17 +0200
commit445cb529b2cae65cbe00c4d49ee5c78e017e1b15 (patch)
tree76d570636242ad78c4f938c58a92391b7cddce15
parent2bdeec83963ed06339281333bbded41553f67926 (diff)
parent4d677ae0e2465188f59ec9226ee16011692286c8 (diff)
downloadphp-git-445cb529b2cae65cbe00c4d49ee5c78e017e1b15.tar.gz
Merge branch 'PHP-7.0'
* PHP-7.0: Fixed bug #72570 Segmentation fault when binding parameters on a query without placeholders Fixed bug #70313 PDO statement fails to throw exception
-rw-r--r--NEWS7
-rw-r--r--ext/pdo_pgsql/pgsql_statement.c5
-rw-r--r--ext/pdo_pgsql/tests/bug70313.phpt37
-rw-r--r--ext/pdo_pgsql/tests/bug72570.phpt28
4 files changed, 75 insertions, 2 deletions
diff --git a/NEWS b/NEWS
index 2dba37f1ce..a3cc2b7ec1 100644
--- a/NEWS
+++ b/NEWS
@@ -10,10 +10,15 @@ PHP NEWS
. Added new constant PHP_FD_SETSIZE. (cmb)
. Added optind parameter to getopt(). (as)
-- Filter
+- Filter:
. Fixed bug #71745 (FILTER_FLAG_NO_RES_RANGE does not cover whole 127.0.0.0/8
range). (bugs dot php dot net at majkl578 dot cz)
+- PDO_pgsql:
+ . Fixed bug #70313 (PDO statement fails to throw exception). (Matteo)
+ . Fixed bug #72570 (Segmentation fault when binding parameters on a query
+ without placeholders). (Matteo)
+
- pcntl
. Implemented asynchronous signal handling without TICKS. (Dmitry)
. Added pcntl_signal_get_handler() that returns the current signal handler
diff --git a/ext/pdo_pgsql/pgsql_statement.c b/ext/pdo_pgsql/pgsql_statement.c
index 6134a733ca..53fea1623a 100644
--- a/ext/pdo_pgsql/pgsql_statement.c
+++ b/ext/pdo_pgsql/pgsql_statement.c
@@ -292,6 +292,9 @@ static int pgsql_stmt_param_hook(pdo_stmt_t *stmt, struct pdo_bound_param_data *
break;
case PDO_PARAM_EVT_ALLOC:
+ if (!stmt->bound_param_map) {
+ return 1;
+ }
if (!zend_hash_index_exists(stmt->bound_param_map, param->paramno)) {
pdo_raise_impl_error(stmt->dbh, stmt, "HY093", "parameter was not defined");
return 0;
@@ -304,7 +307,7 @@ static int pgsql_stmt_param_hook(pdo_stmt_t *stmt, struct pdo_bound_param_data *
case PDO_PARAM_EVT_EXEC_PRE:
if (!stmt->bound_param_map) {
- return 0;
+ return 1;
}
if (!S->param_values) {
S->param_values = ecalloc(
diff --git a/ext/pdo_pgsql/tests/bug70313.phpt b/ext/pdo_pgsql/tests/bug70313.phpt
new file mode 100644
index 0000000000..14c3b7bfcc
--- /dev/null
+++ b/ext/pdo_pgsql/tests/bug70313.phpt
@@ -0,0 +1,37 @@
+--TEST--
+PDO PgSQL Bug #70313 (PDO statement fails to throw exception)
+--SKIPIF--
+<?php
+if (!extension_loaded('pdo') || !extension_loaded('pdo_pgsql')) die('skip not loaded');
+require dirname(__FILE__) . '/config.inc';
+require dirname(__FILE__) . '/../../../ext/pdo/tests/pdo_test.inc';
+PDOTest::skip();
+?>
+--FILE--
+<?php
+require dirname(__FILE__) . '/../../../ext/pdo/tests/pdo_test.inc';
+$db = PDOTest::test_factory(dirname(__FILE__) . '/common.phpt');
+$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
+
+$db->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
+try {
+ $stmt = $db->prepare(");");
+
+ $stmt->execute([1]);
+} catch (PDOException $e) {
+ var_dump($e->getCode());
+}
+
+$db->setAttribute(PDO::ATTR_EMULATE_PREPARES, true);
+try {
+ $stmt = $db->prepare(");");
+
+ $stmt->execute([1]);
+} catch (PDOException $e) {
+ var_dump($e->getCode());
+}
+
+?>
+--EXPECT--
+string(5) "42601"
+string(5) "42601"
diff --git a/ext/pdo_pgsql/tests/bug72570.phpt b/ext/pdo_pgsql/tests/bug72570.phpt
new file mode 100644
index 0000000000..1ac68a3892
--- /dev/null
+++ b/ext/pdo_pgsql/tests/bug72570.phpt
@@ -0,0 +1,28 @@
+--TEST--
+PDO PgSQL Bug #72570 (Segmentation fault when binding parameters on a query without placeholders)
+--SKIPIF--
+<?php
+if (!extension_loaded('pdo') || !extension_loaded('pdo_pgsql')) die('skip not loaded');
+require dirname(__FILE__) . '/config.inc';
+require dirname(__FILE__) . '/../../../ext/pdo/tests/pdo_test.inc';
+PDOTest::skip();
+?>
+--FILE--
+<?php
+require dirname(__FILE__) . '/../../../ext/pdo/tests/pdo_test.inc';
+$db = PDOTest::test_factory(dirname(__FILE__) . '/common.phpt');
+$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
+
+$db->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
+
+$stmt = $db->prepare("SELECT 1");
+
+try {
+ $stmt->execute([1]);
+} catch (PDOException $e) {
+ var_dump($e->getCode());
+}
+
+?>
+--EXPECT--
+string(5) "08P01"