pollita         Thu Jun 19 18:30:54 2003 EDT

  Modified files:              
    /php4/ext/standard  streamsfuncs.c 
  Log:
  Quiet down decode_context_param when stream (not context) is passed.
  Switch stream_socket_*() to use macro for retrieving context from zval.
  
  
Index: php4/ext/standard/streamsfuncs.c
diff -u php4/ext/standard/streamsfuncs.c:1.21 php4/ext/standard/streamsfuncs.c:1.22
--- php4/ext/standard/streamsfuncs.c:1.21       Thu Jun 19 17:04:43 2003
+++ php4/ext/standard/streamsfuncs.c    Thu Jun 19 18:30:54 2003
@@ -17,7 +17,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: streamsfuncs.c,v 1.21 2003/06/19 21:04:43 iliaa Exp $ */
+/* $Id: streamsfuncs.c,v 1.22 2003/06/19 22:30:54 pollita Exp $ */
 
 #include "php.h"
 #include "php_globals.h"
@@ -64,9 +64,7 @@
                RETURN_FALSE;
        }
        
-       if (zcontext) {
-               context = decode_context_param(zcontext TSRMLS_CC);
-       }
+       context = php_stream_context_from_zval(zcontext, flags & 
PHP_FILE_NO_DEFAULT_CONTEXT);
 
        if (flags & PHP_STREAM_CLIENT_PERSISTENT) {
                spprintf(&hashkey, 0, "stream_socket_client__%s", host);
@@ -149,9 +147,7 @@
                RETURN_FALSE;
        }
        
-       if (zcontext) {
-               context = decode_context_param(zcontext TSRMLS_CC);
-       }
+       context = php_stream_context_from_zval(zcontext, flags & 
PHP_FILE_NO_DEFAULT_CONTEXT);
 
        if (zerrno)     {
                zval_dtor(zerrno);
@@ -698,15 +694,19 @@
 {
        php_stream_context *context = NULL;
 
-       context = zend_fetch_resource(&contextresource TSRMLS_CC, -1, 
"Stream-Context", NULL, 1, php_le_stream_context());
+       context = zend_fetch_resource(&contextresource TSRMLS_CC, -1, NULL, NULL, 1, 
php_le_stream_context());
        if (context == NULL) {
                php_stream *stream;
 
-               php_stream_from_zval_no_verify(stream, &contextresource);
+               stream = zend_fetch_resource(&contextresource TSRMLS_CC, -1, NULL, 
NULL, 2, php_file_le_stream(), php_file_le_pstream);
 
                if (stream) {
                        context = stream->context;
                        if (context == NULL) {
+                               /* Only way this happens is if file is opened with 
NO_DEFAULT_CONTEXT
+                                  param, but then something is called which requires 
a context.
+                                  Don't give them the default one though since they 
already said they
+                                  didn't want it. */
                                context = stream->context = php_stream_context_alloc();
                        }
                }
@@ -727,7 +727,10 @@
                RETURN_FALSE;
        }
        context = decode_context_param(zcontext TSRMLS_CC);
-       ZEND_VERIFY_RESOURCE(context);
+       if (!context) {
+               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid stream/context 
parameter.");
+               RETURN_FALSE;
+       }
 
        *return_value = *context->options;
        zval_copy_ctor(return_value);
@@ -756,7 +759,10 @@
 
        /* figure out where the context is coming from exactly */
        context = decode_context_param(zcontext TSRMLS_CC);
-       ZEND_VERIFY_RESOURCE(context);
+       if (!context) {
+               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid stream/context 
parameter.");
+               RETURN_FALSE;
+       }
 
        if (options) {
                /* handle the array syntax */
@@ -780,7 +786,10 @@
        }
 
        context = decode_context_param(zcontext TSRMLS_CC);
-       ZEND_VERIFY_RESOURCE(context);
+       if (!context) {
+               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid stream/context 
parameter.");
+               RETURN_FALSE;
+       }
 
        RETVAL_BOOL(parse_context_params(context, params) == SUCCESS);
 }



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to