]> granicus.if.org Git - php/commitdiff
Fixed bug #72922 COM called from PHP does not return out parameters
authorAnatol Belski <ab@php.net>
Thu, 25 Aug 2016 10:12:45 +0000 (12:12 +0200)
committerAnatol Belski <ab@php.net>
Thu, 25 Aug 2016 10:12:45 +0000 (12:12 +0200)
NEWS
ext/com_dotnet/com_com.c
ext/com_dotnet/com_handlers.c

diff --git a/NEWS b/NEWS
index 20e24b45b9946bbf3f875b276dc5a44a700e5fce..c2c6e2d8c8d24946bc806236ed8fd9b9b260662d 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -10,6 +10,10 @@ PHP                                                                        NEWS
   . Fixed bug #72854 (PHP Crashes on duplicate destructor call). (Nikita)
   . Fixed bug #72857 (stream_socket_recvfrom read access violation). (Anatol)
 
+- COM:
+  . Fixed bug #72922 (COM called from PHP does not return out parameters).
+    (Anatol)
+
 - FTP:
   . Fixed bug #70195 (Cannot upload file using ftp_put to FTPES with
     require_ssl_reuse). (Benedict Singer)
index bb87d8fb2f2e2ad87648dc9346b47a071840dbd0..ec1c72191c86f1fb418f7cccdb2166a4d1458952 100644 (file)
@@ -553,7 +553,10 @@ int php_com_do_invoke_byref(php_com_dotnet_object *obj, zend_internal_function *
                        for (i = 0, j = 0; i < nargs; i++) {
                                /* if this was byref, update the zval */
                                if (f->arg_info[nargs - i - 1].pass_by_reference) {
-                                       SEPARATE_ZVAL_IF_NOT_REF(&args[nargs - i - 1]);
+                                       zval *arg = &args[nargs - i - 1];
+
+                                       ZVAL_DEREF(arg);
+                                       SEPARATE_ZVAL_NOREF(arg);
 
                                        /* if the variant is pointing at the byref_vals, we need to map
                                         * the pointee value as a zval; otherwise, the value is pointing
@@ -561,14 +564,12 @@ int php_com_do_invoke_byref(php_com_dotnet_object *obj, zend_internal_function *
                                        if (V_VT(&vargs[i]) & VT_BYREF) {
                                                if (vargs[i].byref == &V_UINT(&byref_vals[j])) {
                                                        /* copy that value */
-                                                       php_com_zval_from_variant(&args[nargs - i - 1], &byref_vals[j],
-                                                               obj->code_page);
+                                                       php_com_zval_from_variant(arg, &byref_vals[j], obj->code_page);
                                                }
                                        } else {
                                                /* not sure if this can ever happen; the variant we marked as BYREF
                                                 * is no longer BYREF - copy its value */
-                                               php_com_zval_from_variant(&args[nargs - i - 1], &vargs[i],
-                                                       obj->code_page);
+                                               php_com_zval_from_variant(arg, &vargs[i], obj->code_page);
                                        }
                                        VariantClear(&byref_vals[j]);
                                        j++;
index 122c618426ca7606153dd8f0c424404e7a556ca0..415fcb92f40472dfa7c09e53172eb77756415921 100644 (file)
@@ -305,7 +305,8 @@ static union _zend_function *com_method_get(zend_object **object_ptr, zend_strin
                                                        for (i = 0; i < bindptr.lpfuncdesc->cParams; i++) {
                                                                f.arg_info[i].allow_null = 1;
                                                                if (bindptr.lpfuncdesc->lprgelemdescParam[i].paramdesc.wParamFlags & PARAMFLAG_FOUT) {
-                                                                       f.arg_info[i].pass_by_reference = 1;
+                                                                       f.arg_info[i].pass_by_reference = ZEND_SEND_BY_REF;
+                                                                       ZEND_SET_ARG_FLAG(fptr, i + 1, ZEND_SEND_BY_REF);
                                                                }
                                                        }