Skip to content

Commit 4a8cd31

Browse files
authored
ext/odbc: There is no need to rely on ZEND_NUM_ARGS() (#16106)
1 parent dcbba04 commit 4a8cd31

File tree

1 file changed

+13
-16
lines changed

1 file changed

+13
-16
lines changed

ext/odbc/php_odbc.c

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1995,10 +1995,10 @@ PHP_FUNCTION(odbc_result_all)
19951995
}
19961996

19971997
/* Start table tag */
1998-
if (ZEND_NUM_ARGS() == 1) {
1999-
php_printf("<table><tr>");
2000-
} else {
1998+
if (pv_format != NULL) {
20011999
php_printf("<table %s ><tr>", pv_format);
2000+
} else {
2001+
php_printf("<table><tr>");
20022002
}
20032003

20042004
for (i = 0; i < result->numcols; i++) {
@@ -2284,7 +2284,6 @@ void odbc_do_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent)
22842284
size_t db_len, uid_len, pwd_len;
22852285
zend_long pv_opt = SQL_CUR_DEFAULT;
22862286
odbc_connection *db_conn;
2287-
int cur_opt;
22882287

22892288
ZEND_PARSE_PARAMETERS_START(1, 4)
22902289
Z_PARAM_STRING(db, db_len)
@@ -2294,19 +2293,17 @@ void odbc_do_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent)
22942293
Z_PARAM_LONG(pv_opt)
22952294
ZEND_PARSE_PARAMETERS_END();
22962295

2297-
cur_opt = pv_opt;
2298-
2299-
if (ZEND_NUM_ARGS() > 3) {
2300-
/* Confirm the cur_opt range */
2301-
if (! (cur_opt == SQL_CUR_USE_IF_NEEDED ||
2302-
cur_opt == SQL_CUR_USE_ODBC ||
2303-
cur_opt == SQL_CUR_USE_DRIVER ||
2304-
cur_opt == SQL_CUR_DEFAULT) ) {
2305-
zend_argument_value_error(4, "must be one of SQL_CUR_USE_IF_NEEDED, "
2306-
"SQL_CUR_USE_ODBC, or SQL_CUR_USE_DRIVER");
2307-
RETURN_THROWS();
2308-
}
2296+
if (
2297+
pv_opt != SQL_CUR_DEFAULT
2298+
&& pv_opt != SQL_CUR_USE_IF_NEEDED
2299+
&& pv_opt != SQL_CUR_USE_ODBC
2300+
&& pv_opt != SQL_CUR_USE_DRIVER
2301+
) {
2302+
zend_argument_value_error(4, "must be one of SQL_CUR_USE_IF_NEEDED, "
2303+
"SQL_CUR_USE_ODBC, or SQL_CUR_USE_DRIVER");
2304+
RETURN_THROWS();
23092305
}
2306+
int cur_opt = (int) pv_opt;
23102307

23112308
if (!ODBCG(allow_persistent)) {
23122309
persistent = 0;

0 commit comments

Comments
 (0)