Re: cvs: php4 /ext/standard fsock.c
| From: | Andi Gutmans | Date: | Thu, 19 Oct 2000 13:42:32 +0000 |
| Subject: | Re: cvs: php4 /ext/standard fsock.c | ||
| References: | 1 2 3 4 5 6 | Groups: | php.cvs |
| Request: | Send a blank email to php-cvs+get-2130@lists.php.net to get a copy of this message | ||
At 01:48 PM 10/19/00 +0200, Stig Venaas wrote:
On Wed, Oct 18, 2000 at 11:46:09PM +0200, Andi Gutmans wrote: Basically if you are using the _ex functions the resulting zval **'s are read-only. If you just simply convert the zval **'s to zval *'s and use the non-_ex functions you should be just fine. You are allowed to change their values. Just make sure you don't touch the reference count and is_ref. I've studied the code carefully, and I think the code was right. Here is how I understand it: The arguments that are to be changed inside fsockopen are forced to be references. Since they are to be references, the macro SEPARATE_ZVAL_TO_MAKE_IS_REF will be called when the arguments are prepared before calling fsockopen. This macro uses SEPARATE_ZVAL which copies the zval if refcount>1. After that the _ex function is used, it doesn't copy anything but that's okay since they were copied already. Actually the non-_ex function doesn't copy references either, which is correct. If the arguments were not forced to be references however, any change of the arguments inside fsockopen would leak out unless one uses the non-_ex function which copies it. So my conclusion is that fsockopen is correct even though it's using the _ex-function.Yes you are right (although I haven't looked at all of the code). If it's only the third and fourth argument which are changed according to the definition of the function:
PHP_FE(fsockopen, third_and_fourth_args_force_ref)They will be references and thus you are allowed to change them. Andi --- Andi Gutmans <andi@zend.com> http://www.zend.com/