Skip to content

Commit 07fa130

Browse files
committed
Revert "Use external iterator instead of via the internal pointer"
This reverts commit a6ecafe. Closes GH-6242.
1 parent c907413 commit 07fa130

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

ext/odbc/php_odbc.c

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -977,7 +977,7 @@ PHP_FUNCTION(odbc_execute)
977977
int i, ne;
978978
RETCODE rc;
979979

980-
if (zend_parse_parameters(ZEND_NUM_ARGS(), "r|h", &pv_res, &pv_param_ht) == FAILURE) {
980+
if (zend_parse_parameters(ZEND_NUM_ARGS(), "r|h/", &pv_res, &pv_param_ht) == FAILURE) {
981981
RETURN_THROWS();
982982
}
983983

@@ -991,13 +991,25 @@ PHP_FUNCTION(odbc_execute)
991991
RETURN_FALSE;
992992
}
993993

994+
zend_hash_internal_pointer_reset(pv_param_ht);
994995
params = (params_t *)safe_emalloc(sizeof(params_t), result->numparams, 0);
995996
for(i = 0; i < result->numparams; i++) {
996997
params[i].fp = -1;
997998
}
998999

999-
i = 1;
1000-
ZEND_HASH_FOREACH_VAL(pv_param_ht, tmp) {
1000+
for(i = 1; i <= result->numparams; i++) {
1001+
if ((tmp = zend_hash_get_current_data(pv_param_ht)) == NULL) {
1002+
php_error_docref(NULL, E_WARNING,"Error getting parameter");
1003+
SQLFreeStmt(result->stmt,SQL_RESET_PARAMS);
1004+
for (i = 0; i < result->numparams; i++) {
1005+
if (params[i].fp != -1) {
1006+
close(params[i].fp);
1007+
}
1008+
}
1009+
efree(params);
1010+
RETURN_FALSE;
1011+
}
1012+
10011013
otype = Z_TYPE_P(tmp);
10021014
if (!try_convert_to_string(tmp)) {
10031015
SQLFreeStmt(result->stmt, SQL_RESET_PARAMS);
@@ -1087,8 +1099,8 @@ PHP_FUNCTION(odbc_execute)
10871099
efree(params);
10881100
RETURN_FALSE;
10891101
}
1090-
if (++i > result->numparams) break;
1091-
} ZEND_HASH_FOREACH_END();
1102+
zend_hash_move_forward(pv_param_ht);
1103+
}
10921104
}
10931105
/* Close cursor, needed for doing multiple selects */
10941106
rc = SQLFreeStmt(result->stmt, SQL_CLOSE);

0 commit comments

Comments
 (0)