1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00

ext/odbc: There is no need to rely on ZEND_NUM_ARGS() (#16106)

This commit is contained in:
Gina Peter Banyard
2024-09-28 21:31:42 +01:00
committed by GitHub
parent dcbba04d38
commit 4a8cd31d51

View File

@@ -1995,10 +1995,10 @@ PHP_FUNCTION(odbc_result_all)
}
/* Start table tag */
if (ZEND_NUM_ARGS() == 1) {
php_printf("<table><tr>");
} else {
if (pv_format != NULL) {
php_printf("<table %s ><tr>", pv_format);
} else {
php_printf("<table><tr>");
}
for (i = 0; i < result->numcols; i++) {
@@ -2284,7 +2284,6 @@ void odbc_do_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent)
size_t db_len, uid_len, pwd_len;
zend_long pv_opt = SQL_CUR_DEFAULT;
odbc_connection *db_conn;
int cur_opt;
ZEND_PARSE_PARAMETERS_START(1, 4)
Z_PARAM_STRING(db, db_len)
@@ -2294,19 +2293,17 @@ void odbc_do_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent)
Z_PARAM_LONG(pv_opt)
ZEND_PARSE_PARAMETERS_END();
cur_opt = pv_opt;
if (ZEND_NUM_ARGS() > 3) {
/* Confirm the cur_opt range */
if (! (cur_opt == SQL_CUR_USE_IF_NEEDED ||
cur_opt == SQL_CUR_USE_ODBC ||
cur_opt == SQL_CUR_USE_DRIVER ||
cur_opt == SQL_CUR_DEFAULT) ) {
zend_argument_value_error(4, "must be one of SQL_CUR_USE_IF_NEEDED, "
"SQL_CUR_USE_ODBC, or SQL_CUR_USE_DRIVER");
RETURN_THROWS();
}
if (
pv_opt != SQL_CUR_DEFAULT
&& pv_opt != SQL_CUR_USE_IF_NEEDED
&& pv_opt != SQL_CUR_USE_ODBC
&& pv_opt != SQL_CUR_USE_DRIVER
) {
zend_argument_value_error(4, "must be one of SQL_CUR_USE_IF_NEEDED, "
"SQL_CUR_USE_ODBC, or SQL_CUR_USE_DRIVER");
RETURN_THROWS();
}
int cur_opt = (int) pv_opt;
if (!ODBCG(allow_persistent)) {
persistent = 0;