From f2ec3fa6e5056ca541dcf4b6a03a3b39536aa91d Mon Sep 17 00:00:00 2001 From: Dan Kalowsky Date: Thu, 14 Jun 2001 15:02:17 +0000 Subject: [PATCH] adding in some error checking for parameter counts, and some thread safety for functions --- ext/odbc/php_odbc.c | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/ext/odbc/php_odbc.c b/ext/odbc/php_odbc.c index 60ba594ce1..bca98d26b8 100644 --- a/ext/odbc/php_odbc.c +++ b/ext/odbc/php_odbc.c @@ -778,6 +778,7 @@ PHP_FUNCTION(odbc_prepare) #ifdef HAVE_SQL_EXTENDED_FETCH UDWORD scrollopts; #endif + ODBCLS_FETCH(); if (zend_get_parameters_ex(2, &pv_conn, &pv_query) == FAILURE) { WRONG_PARAM_COUNT; @@ -882,20 +883,25 @@ PHP_FUNCTION(odbc_execute) odbc_result *result; int numArgs, i, ne; RETCODE rc; + ODBCLS_FETCH(); numArgs = ZEND_NUM_ARGS(); - if (numArgs == 1) { - if (zend_get_parameters_ex(1, &pv_res) == FAILURE) - WRONG_PARAM_COUNT; - } else { - if (zend_get_parameters_ex(2, &pv_res, &pv_param_arr) == FAILURE) + switch(numArgs) { + case 1: + if (zend_get_parameters_ex(1, &pv_res) == FAILURE) + WRONG_PARAM_COUNT; + break; + case 2: + if (zend_get_parameters_ex(2, &pv_res, &pv_param_arr) == FAILURE) + WRONG_PARAM_COUNT; + if ((*pv_param_arr)->type != IS_ARRAY) { + php_error(E_WARNING, "No array passed to odbc_execute()"); + return; + } + break; + default: WRONG_PARAM_COUNT; - - if ((*pv_param_arr)->type != IS_ARRAY) { - php_error(E_WARNING, "No array passed to odbc_execute()"); - return; - } - } + } ZEND_FETCH_RESOURCE(result, odbc_result *, pv_res, -1, "ODBC result", le_result); -- 2.50.1