Skip to content

Commit ff2f882

Browse files
committed
Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1: Fix missing and inconsistent error check on SQLAllocHandle
2 parents 420469b + c4c8d6c commit ff2f882

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ PHP NEWS
3636
. Add missing error checks on EVP_MD_CTX_create() and EVP_VerifyInit().
3737
(nielsdos)
3838

39+
- PDO ODBC:
40+
. Fixed missing and inconsistent error checks on SQLAllocHandle. (nielsdos)
41+
3942
- SPL:
4043
. Fixed bug GH-10519 (Array Data Address Reference Issue). (Nathan Freeman)
4144

ext/pdo_odbc/odbc_driver.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ static zend_long odbc_handle_doer(pdo_dbh_t *dbh, const zend_string *sql)
222222
PDO_ODBC_HSTMT stmt;
223223

224224
rc = SQLAllocHandle(SQL_HANDLE_STMT, H->dbc, &stmt);
225-
if (rc != SQL_SUCCESS) {
225+
if (rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) {
226226
pdo_odbc_drv_error("SQLAllocHandle: STMT");
227227
return -1;
228228
}
@@ -449,7 +449,12 @@ static int pdo_odbc_handle_factory(pdo_dbh_t *dbh, zval *driver_options) /* {{{
449449

450450
dbh->driver_data = H;
451451

452-
SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &H->env);
452+
rc = SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &H->env);
453+
if (rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) {
454+
pdo_odbc_drv_error("SQLAllocHandle: ENV");
455+
goto fail;
456+
}
457+
453458
rc = SQLSetEnvAttr(H->env, SQL_ATTR_ODBC_VERSION, (void*)SQL_OV_ODBC3, 0);
454459

455460
if (rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) {
@@ -469,7 +474,7 @@ static int pdo_odbc_handle_factory(pdo_dbh_t *dbh, zval *driver_options) /* {{{
469474

470475
rc = SQLAllocHandle(SQL_HANDLE_DBC, H->env, &H->dbc);
471476
if (rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) {
472-
pdo_odbc_drv_error("SQLAllocHandle (DBC)");
477+
pdo_odbc_drv_error("SQLAllocHandle: DBC");
473478
goto fail;
474479
}
475480

0 commit comments

Comments
 (0)