Skip to content

Commit bf5f07c

Browse files
committed
Fix #80152: odbc_execute() moves internal pointer of $params
As least intrusive fix, we separate the passed array argument. Closes GH-6219.
1 parent df5efa2 commit bf5f07c

File tree

3 files changed

+28
-1
lines changed

3 files changed

+28
-1
lines changed

NEWS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ PHP NEWS
1717
. Fixed bug #80147 (BINARY strings may not be properly zero-terminated).
1818
(cmb)
1919
. Fixed bug #80150 (Failure to fetch error message). (cmb)
20+
. Fixed bug #80152 (odbc_execute() moves internal pointer of $params). (cmb)
2021

2122
- OPcache:
2223
. Fixed bug #80083 (Optimizer pass 6 removes variables used for ibm_db2 data

ext/odbc/php_odbc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1309,7 +1309,7 @@ PHP_FUNCTION(odbc_execute)
13091309
int numArgs = ZEND_NUM_ARGS(), i, ne;
13101310
RETCODE rc;
13111311

1312-
if (zend_parse_parameters(numArgs, "r|a", &pv_res, &pv_param_arr) == FAILURE) {
1312+
if (zend_parse_parameters(numArgs, "r|a/", &pv_res, &pv_param_arr) == FAILURE) {
13131313
return;
13141314
}
13151315

ext/odbc/tests/bug80152.phpt

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
--TEST--
2+
Bug #80152 (odbc_execute() moves internal pointer of $params)
3+
--SKIPIF--
4+
<?php include 'skipif.inc'; ?>
5+
--FILE--
6+
<?php
7+
include 'config.inc';
8+
9+
$conn = odbc_connect($dsn, $user, $pass);
10+
odbc_exec($conn,"CREATE TABLE bug80152 (id INT, name CHAR(24))");
11+
$stmt = odbc_prepare($conn,"INSERT INTO bug80152 (id, name) VALUES (?, ?)");
12+
$params = [1, "John", "Lim"];
13+
var_dump(key($params));
14+
odbc_execute($stmt, $params);
15+
var_dump(key($params));
16+
?>
17+
--CLEAN--
18+
<?php
19+
include 'config.inc';
20+
21+
$conn = odbc_connect($dsn, $user, $pass);
22+
odbc_exec($conn, "DROP TABLE bug80152");
23+
?>
24+
--EXPECT--
25+
int(0)
26+
int(0)

0 commit comments

Comments
 (0)