]> granicus.if.org Git - php/commitdiff
Fix my favourite call user func mistake
authorWez Furlong <wez@php.net>
Thu, 29 Jul 2004 14:06:24 +0000 (14:06 +0000)
committerWez Furlong <wez@php.net>
Thu, 29 Jul 2004 14:06:24 +0000 (14:06 +0000)
ext/com_dotnet/com_handlers.c
ext/com_dotnet/com_wrapper.c

index cee0b41017598466f28be8fca638bfc50ab682b2..82713c67c7fb7dcd47cce4b7f39d69f071c0530c 100644 (file)
@@ -321,7 +321,7 @@ static union _zend_function *com_method_get(zval *object, char *name, int len TS
                f.handler = PHP_FN(com_method_handler);
 
                fptr = &f;
-               
+       
                if (obj->typeinfo) {
                        /* look for byref params */
                        ITypeComp *comp;
@@ -524,7 +524,7 @@ static int com_object_cast(zval *readobj, zval *writeobj, int type, int should_f
        php_com_dotnet_object *obj;
        VARIANT v;
        VARTYPE vt = VT_EMPTY;
-
+       
        if (should_free) {
                zval_dtor(writeobj);
        }
@@ -535,7 +535,6 @@ static int com_object_cast(zval *readobj, zval *writeobj, int type, int should_f
        VariantInit(&v);
 
        if (V_VT(&obj->v) == VT_DISPATCH) {
-
                if (!obj->have_default_bind && !com_get_default_binding(obj TSRMLS_CC)) {
                        return FAILURE;
                }
@@ -561,9 +560,11 @@ static int com_object_cast(zval *readobj, zval *writeobj, int type, int should_f
                case IS_STRING:
                        vt = VT_BSTR;
                        break;
+               default:
+                       ;
        }
 
-       if (vt != VT_EMPTY) {
+       if (vt != VT_EMPTY && vt != V_VT(&v)) {
                VariantChangeType(&v, &v, 0, vt);
        }
 
index f9f35a34173d3ca5a7d122a09399a051a42d8382..d07ec8668895c577e0eff95cfbf1f5552c7ab760 100644 (file)
@@ -90,7 +90,7 @@ static inline void trace(char *fmt, ...)
        php_dispatchex *disp = (php_dispatchex*)This; \
        trace(" PHP:%s %s\n", Z_OBJCE_P(disp->object)->name, methname); \
        if (tsrm_thread_id() != disp->engine_thread) \
-               return E_UNEXPECTED;
+               return RPC_E_WRONG_THREAD;
 
 
 static HRESULT STDMETHODCALLTYPE disp_queryinterface( 
@@ -287,7 +287,8 @@ static HRESULT STDMETHODCALLTYPE disp_invokeex(
 
                                ALLOC_INIT_ZVAL(zarg);
                                php_com_wrap_variant(zarg, arg, COMG(code_page) TSRMLS_CC);
-                               params[i] = &zarg;
+                               params[i] = (zval**)emalloc(sizeof(zval**));
+                               *params[i] = zarg;
                        }
                }
 
@@ -320,8 +321,10 @@ static HRESULT STDMETHODCALLTYPE disp_invokeex(
        
                /* release arguments */
                if (params) {
-                       for (i = 0; i < pdp->cArgs; i++)
+                       for (i = 0; i < pdp->cArgs; i++) {
                                zval_ptr_dtor(params[i]);
+                               efree(params[i]);
+                       }
                        efree(params);
                }
                
@@ -625,8 +628,9 @@ PHPAPI IDispatch *php_com_wrapper_export(zval *val TSRMLS_DC)
 {
        php_dispatchex *disp = NULL;
 
-       if (Z_TYPE_P(val) != IS_OBJECT)
+       if (Z_TYPE_P(val) != IS_OBJECT) {
                return NULL;
+       }
 
        if (php_com_is_valid_object(val TSRMLS_CC)) {
                /* pass back its IDispatch directly */