Re: Bug #7488, where I tripped upon the fact that call-time
pass-by-reference, while deprecated in the language, is required by
some functions. (The one which bit me was odbc_fetch_into(), but
exec(), getmxrr(), and a few others also appear to require it).

For the case of odbc_fetch_into(), the following patch seems to fix
it. If someone reads this, could they tell me whether I've got the
right idea about SEPARATE_ZVAL() there? Since the function takes 2 or
three args, and the last one always needs to be a reference, I took
the liberty of making both of the last 2 forced refs. I am under the
impression that SEPARATE_ZVAL(pv_row) is the correct way to protect
the one which I don't want passed by ref; is this correct?

Index: php_odbc.c
===================================================================
RCS file: /repository/php4/ext/odbc/php_odbc.c,v
retrieving revision 1.75
diff -u -r1.75 php_odbc.c
--- php_odbc.c  2001/03/27 15:46:27     1.75
+++ php_odbc.c  2001/03/28 19:59:48
@@ -63,7 +63,7 @@
 
 #define SAFE_SQL_NTS(n) ((SWORD) ((n)?(SQL_NTS):0))
 
-static unsigned char a3_arg3_force_ref[] = { 3, BYREF_NONE, BYREF_ALLOW, BYREF_FORCE 
};
+static unsigned char a3_arg2_and_3_force_ref[] = { 3, BYREF_NONE, BYREF_FORCE, 
+BYREF_FORCE };
 
 function_entry odbc_functions[] = {
     PHP_FE(odbc_error, NULL)
@@ -84,7 +84,7 @@
        PHP_FE(odbc_prepare, NULL)
        PHP_FE(odbc_execute, NULL)
        PHP_FE(odbc_fetch_row, NULL)
-       PHP_FE(odbc_fetch_into, a3_arg3_force_ref)
+       PHP_FE(odbc_fetch_into, a3_arg2_and_3_force_ref)
        PHP_FE(odbc_field_len, NULL)
        PHP_FE(odbc_field_scale, NULL)
        PHP_FE(odbc_field_name, NULL)
@@ -1349,6 +1349,7 @@
                case 3:
                        if (zend_get_parameters_ex(3, &pv_res, &pv_row, &pv_res_arr) 
== FAILURE)
                                WRONG_PARAM_COUNT;
+                       SEPARATE_ZVAL(pv_row);
                        convert_to_long_ex(pv_row);
                        rownum = (*pv_row)->value.lval;
                        break;
@@ -1365,11 +1366,6 @@
                WRONG_PARAM_COUNT;
        }
 #endif
-       
-       if (!ParameterPassedByReference(ht, numArgs)) {
-               php_error(E_WARNING, "Array not passed by reference in call to 
odbc_fetch_into()");
-               RETURN_FALSE;
-       }
 
        ZEND_FETCH_RESOURCE(result, odbc_result *, pv_res, -1, "ODBC result", 
le_result);
        



-- 
+----------------------------------------------------------------+
|Torben Wilson <[EMAIL PROTECTED]>                    Adcore Finland|
|http://www.coastnet.com/~torben            http://www.adcore.com|
|Ph: 1.604.709.0506                             [EMAIL PROTECTED]|
+----------------------------------------------------------------+

-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to