Skip to content

Commit 99b3631

Browse files
committed
Merge branch 'PHP-7.4' into master
* PHP-7.4: Fix #67465: NULL Pointer dereference in odbc_handle_preparer
2 parents f722512 + f1d8395 commit 99b3631

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

ext/pdo_odbc/odbc_driver.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,8 @@ static int odbc_handle_preparer(pdo_dbh_t *dbh, const char *sql, size_t sql_len,
177177
return 0;
178178
}
179179

180+
stmt->driver_data = S;
181+
180182
cursor_type = pdo_attr_lval(driver_options, PDO_ATTR_CURSOR, PDO_CURSOR_FWDONLY);
181183
if (cursor_type != PDO_CURSOR_FWDONLY) {
182184
rc = SQLSetStmtAttr(S->stmt, SQL_ATTR_CURSOR_SCROLLABLE, (void*)SQL_SCROLLABLE, 0);
@@ -195,7 +197,6 @@ static int odbc_handle_preparer(pdo_dbh_t *dbh, const char *sql, size_t sql_len,
195197
efree(nsql);
196198
}
197199

198-
stmt->driver_data = S;
199200
stmt->methods = &odbc_stmt_methods;
200201

201202
if (rc != SQL_SUCCESS) {

ext/pdo_odbc/tests/bug67465.phpt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
--TEST--
2+
Bug #67465 (NULL Pointer dereference in odbc_handle_preparer)
3+
--SKIPIF--
4+
<?php
5+
if (!extension_loaded('pdo_odbc')) die('skip pdo_odbc extension not available');
6+
require 'ext/pdo/tests/pdo_test.inc';
7+
PDOTest::skip();
8+
?>
9+
--FILE--
10+
<?php
11+
require 'ext/pdo/tests/pdo_test.inc';
12+
$db = PDOTest::test_factory(dirname(__FILE__) . '/common.phpt');
13+
$db->prepare("SELECT 1", [PDO::ATTR_CURSOR => PDO::CURSOR_SCROLL]);
14+
echo "done\n";
15+
?>
16+
--EXPECT--
17+
done

0 commit comments

Comments
 (0)