Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 28, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 13 additions & 16 deletions ext/odbc/php_odbc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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++) {
Expand Down Expand Up @@ -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)
Expand All @@ -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;
Expand Down