summaryrefslogtreecommitdiff
path: root/ext/com_dotnet
diff options
context:
space:
mode:
authorMark A. Hershberger <mah@debian.(none)>2009-03-25 00:37:27 -0400
committerMark A. Hershberger <mah@debian.(none)>2009-03-25 00:37:27 -0400
commit2d4e5b09576bb4f0ba716cc82cdf29ea04d9184b (patch)
tree41ccc042009cba53e4ce43e727fcba4c1cfbf7f3 /ext/com_dotnet
parentd29a4fd2dd3b5d4cf6e80b602544d7b71d794e76 (diff)
downloadphp-upstream/5.2.2.tar.gz
Imported Upstream version 5.2.2upstream/5.2.2
Diffstat (limited to 'ext/com_dotnet')
-rw-r--r--ext/com_dotnet/com_com.c27
-rw-r--r--ext/com_dotnet/com_dotnet.c15
-rw-r--r--ext/com_dotnet/com_extension.c6
-rw-r--r--ext/com_dotnet/com_handlers.c15
-rw-r--r--ext/com_dotnet/com_iterator.c4
-rw-r--r--ext/com_dotnet/com_misc.c7
-rw-r--r--ext/com_dotnet/com_olechar.c10
-rwxr-xr-xext/com_dotnet/com_persist.c4
-rw-r--r--ext/com_dotnet/com_saproxy.c8
-rw-r--r--ext/com_dotnet/com_typeinfo.c10
-rw-r--r--ext/com_dotnet/com_variant.c185
-rw-r--r--ext/com_dotnet/com_wrapper.c52
-rw-r--r--ext/com_dotnet/package.xml2
-rw-r--r--ext/com_dotnet/php_com_dotnet.h5
-rw-r--r--ext/com_dotnet/php_com_dotnet_internal.h12
-rw-r--r--ext/com_dotnet/tests/bug33386.phpt40
-rw-r--r--ext/com_dotnet/tests/bug39596.phpt23
-rw-r--r--ext/com_dotnet/tests/bug39606.phpt22
18 files changed, 368 insertions, 79 deletions
diff --git a/ext/com_dotnet/com_com.c b/ext/com_dotnet/com_com.c
index b48cd2ff7..28b4b2ec5 100644
--- a/ext/com_dotnet/com_com.c
+++ b/ext/com_dotnet/com_com.c
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2006 The PHP Group |
+ | Copyright (c) 1997-2007 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: com_com.c,v 1.16.2.2.2.1 2006/10/10 17:32:50 iliaa Exp $ */
+/* $Id: com_com.c,v 1.16.2.2.2.5 2007/04/09 15:32:08 dmitry Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -53,6 +53,7 @@ PHP_FUNCTION(com_create_instance)
&authid, EOAC_NONE
};
+ php_com_initialize(TSRMLS_C);
obj = CDNO_FETCH(object);
if (FAILURE == zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET,
@@ -294,6 +295,7 @@ PHP_FUNCTION(com_get_active_object)
HRESULT res;
OLECHAR *module = NULL;
+ php_com_initialize(TSRMLS_C);
if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|l",
&module_name, &module_name_len, &code_page)) {
php_com_throw_exception(E_INVALIDARG, "Invalid arguments!" TSRMLS_CC);
@@ -336,7 +338,7 @@ PHP_FUNCTION(com_get_active_object)
/* Performs an Invoke on the given com object.
* returns a failure code and creates an exception if there was an error */
HRESULT php_com_invoke_helper(php_com_dotnet_object *obj, DISPID id_member,
- WORD flags, DISPPARAMS *disp_params, VARIANT *v, int silent TSRMLS_DC)
+ WORD flags, DISPPARAMS *disp_params, VARIANT *v, int silent, int allow_noarg TSRMLS_DC)
{
HRESULT hr;
unsigned int arg_err;
@@ -387,7 +389,7 @@ HRESULT php_com_invoke_helper(php_com_dotnet_object *obj, DISPID id_member,
break;
case DISP_E_BADPARAMCOUNT:
- if ((disp_params->cArgs + disp_params->cNamedArgs == 0) && (flags == DISPATCH_PROPERTYGET)) {
+ if ((disp_params->cArgs + disp_params->cNamedArgs == 0) && (allow_noarg == 1)) {
/* if getting a property and they are missing all parameters,
* we want to create a proxy object for them; so lets not create an
* exception here */
@@ -543,7 +545,7 @@ int php_com_do_invoke_byref(php_com_dotnet_object *obj, char *name, int namelen,
}
/* this will create an exception if needed */
- hr = php_com_invoke_helper(obj, dispid, flags, &disp_params, v, 0 TSRMLS_CC);
+ hr = php_com_invoke_helper(obj, dispid, flags, &disp_params, v, 0, 0 TSRMLS_CC);
/* release variants */
if (vargs) {
@@ -581,7 +583,7 @@ int php_com_do_invoke_byref(php_com_dotnet_object *obj, char *name, int namelen,
int php_com_do_invoke_by_id(php_com_dotnet_object *obj, DISPID dispid,
- WORD flags, VARIANT *v, int nargs, zval **args, int silent TSRMLS_DC)
+ WORD flags, VARIANT *v, int nargs, zval **args, int silent, int allow_noarg TSRMLS_DC)
{
DISPID altdispid;
DISPPARAMS disp_params;
@@ -610,7 +612,7 @@ int php_com_do_invoke_by_id(php_com_dotnet_object *obj, DISPID dispid,
}
/* this will create an exception if needed */
- hr = php_com_invoke_helper(obj, dispid, flags, &disp_params, v, silent TSRMLS_CC);
+ hr = php_com_invoke_helper(obj, dispid, flags, &disp_params, v, silent, allow_noarg TSRMLS_CC);
/* release variants */
if (vargs) {
@@ -628,7 +630,7 @@ int php_com_do_invoke_by_id(php_com_dotnet_object *obj, DISPID dispid,
}
int php_com_do_invoke(php_com_dotnet_object *obj, char *name, int namelen,
- WORD flags, VARIANT *v, int nargs, zval **args TSRMLS_DC)
+ WORD flags, VARIANT *v, int nargs, zval **args, int allow_noarg TSRMLS_DC)
{
DISPID dispid;
HRESULT hr;
@@ -646,7 +648,7 @@ int php_com_do_invoke(php_com_dotnet_object *obj, char *name, int namelen,
return FAILURE;
}
- return php_com_do_invoke_by_id(obj, dispid, flags, v, nargs, args, 0 TSRMLS_CC);
+ return php_com_do_invoke_by_id(obj, dispid, flags, v, nargs, args, 0, allow_noarg TSRMLS_CC);
}
/* {{{ proto string com_create_guid()
@@ -660,9 +662,10 @@ PHP_FUNCTION(com_create_guid)
ZEND_WRONG_PARAM_COUNT();
}
+ php_com_initialize(TSRMLS_C);
if (CoCreateGuid(&retval) == S_OK && StringFromCLSID(&retval, &guid_string) == S_OK) {
Z_TYPE_P(return_value) = IS_STRING;
- Z_STRVAL_P(return_value) = php_com_olestring_to_string(guid_string, &Z_STRLEN_P(return_value), CP_ACP, 0);
+ Z_STRVAL_P(return_value) = php_com_olestring_to_string(guid_string, &Z_STRLEN_P(return_value), CP_ACP TSRMLS_CC);
CoTaskMemFree(guid_string);
} else {
@@ -688,6 +691,7 @@ PHP_FUNCTION(com_event_sink)
RETURN_FALSE;
}
+ php_com_initialize(TSRMLS_C);
obj = CDNO_FETCH(object);
if (sink && Z_TYPE_P(sink) == IS_ARRAY) {
@@ -748,6 +752,7 @@ PHP_FUNCTION(com_print_typeinfo)
RETURN_FALSE;
}
+ php_com_initialize(TSRMLS_C);
if (Z_TYPE_P(arg1) == IS_OBJECT) {
CDNO_FETCH_VERIFY(obj, arg1);
} else {
@@ -778,6 +783,7 @@ PHP_FUNCTION(com_message_pump)
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &timeoutms) == FAILURE)
RETURN_FALSE;
+ php_com_initialize(TSRMLS_C);
result = MsgWaitForMultipleObjects(0, NULL, FALSE, timeoutms, QS_ALLINPUT);
if (result == WAIT_OBJECT_0) {
@@ -811,6 +817,7 @@ PHP_FUNCTION(com_load_typelib)
RETVAL_FALSE;
+ php_com_initialize(TSRMLS_C);
pTL = php_com_load_typelib_via_cache(name, codepage, &cached TSRMLS_CC);
if (pTL) {
if (cached) {
diff --git a/ext/com_dotnet/com_dotnet.c b/ext/com_dotnet/com_dotnet.c
index 2aa8e8031..adcb330be 100644
--- a/ext/com_dotnet/com_dotnet.c
+++ b/ext/com_dotnet/com_dotnet.c
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2006 The PHP Group |
+ | Copyright (c) 1997-2007 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: com_dotnet.c,v 1.14.2.1 2006/01/01 12:50:00 sniper Exp $ */
+/* $Id: com_dotnet.c,v 1.14.2.1.2.4 2007/02/21 01:11:11 stas Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -188,11 +188,13 @@ PHP_FUNCTION(com_dotnet_create_instance)
int assembly_name_len, datatype_name_len;
struct dotnet_runtime_stuff *stuff;
OLECHAR *oleassembly, *oletype;
+ BSTR oleassembly_sys, oletype_sys;
HRESULT hr;
int ret = FAILURE;
char *where = "";
IUnknown *unk = NULL;
+ php_com_initialize(TSRMLS_C);
if (COMG(dotnet_runtime_stuff) == NULL) {
hr = dotnet_init(&where TSRMLS_CC);
if (FAILED(hr)) {
@@ -222,10 +224,14 @@ PHP_FUNCTION(com_dotnet_create_instance)
oletype = php_com_string_to_olestring(datatype_name, datatype_name_len, obj->code_page TSRMLS_CC);
oleassembly = php_com_string_to_olestring(assembly_name, assembly_name_len, obj->code_page TSRMLS_CC);
+ oletype_sys = SysAllocString(oletype);
+ oleassembly_sys = SysAllocString(oleassembly);
where = "CreateInstance";
- hr = stuff->dotnet_domain->lpVtbl->CreateInstance(stuff->dotnet_domain, oleassembly, oletype, &unk);
+ hr = stuff->dotnet_domain->lpVtbl->CreateInstance(stuff->dotnet_domain, oleassembly_sys, oletype_sys, &unk);
efree(oletype);
efree(oleassembly);
+ SysFreeString(oletype_sys);
+ SysFreeString(oleassembly_sys);
if (SUCCEEDED(hr)) {
VARIANT unwrapped;
@@ -274,8 +280,9 @@ PHP_FUNCTION(com_dotnet_create_instance)
char buf[1024];
char *err = php_win_err(hr);
snprintf(buf, sizeof(buf), "Failed to instantiate .Net object [%s] [0x%08x] %s", where, hr, err);
- if (err)
+ if (err && err[0]) {
LocalFree(err);
+ }
php_com_throw_exception(hr, buf TSRMLS_CC);
ZVAL_NULL(object);
return;
diff --git a/ext/com_dotnet/com_extension.c b/ext/com_dotnet/com_extension.c
index c043d53f9..ae8b73c73 100644
--- a/ext/com_dotnet/com_extension.c
+++ b/ext/com_dotnet/com_extension.c
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2006 The PHP Group |
+ | Copyright (c) 1997-2007 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: com_extension.c,v 1.17.2.2.2.4 2006/10/18 23:47:33 iliaa Exp $ */
+/* $Id: com_extension.c,v 1.17.2.2.2.6 2007/03/05 15:49:00 wharmby Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -315,6 +315,7 @@ PHP_MSHUTDOWN_FUNCTION(com_dotnet)
*/
PHP_RINIT_FUNCTION(com_dotnet)
{
+ COMG(rshutdown_started) = 0;
return SUCCESS;
}
/* }}} */
@@ -328,6 +329,7 @@ PHP_RSHUTDOWN_FUNCTION(com_dotnet)
php_com_dotnet_rshutdown(TSRMLS_C);
}
#endif
+ COMG(rshutdown_started) = 1;
return SUCCESS;
}
/* }}} */
diff --git a/ext/com_dotnet/com_handlers.c b/ext/com_dotnet/com_handlers.c
index 1815af9dc..e277339d0 100644
--- a/ext/com_dotnet/com_handlers.c
+++ b/ext/com_dotnet/com_handlers.c
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2006 The PHP Group |
+ | Copyright (c) 1997-2007 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: com_handlers.c,v 1.30.2.5.2.2 2006/10/06 12:23:30 edink Exp $ */
+/* $Id: com_handlers.c,v 1.30.2.5.2.6 2007/01/01 09:35:48 sebastian Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -49,7 +49,7 @@ static zval *com_property_read(zval *object, zval *member, int type TSRMLS_DC)
convert_to_string_ex(&member);
res = php_com_do_invoke(obj, Z_STRVAL_P(member), Z_STRLEN_P(member),
- DISPATCH_METHOD|DISPATCH_PROPERTYGET, &v, 0, NULL TSRMLS_CC);
+ DISPATCH_METHOD|DISPATCH_PROPERTYGET, &v, 0, NULL, 1 TSRMLS_CC);
if (res == SUCCESS) {
php_com_zval_from_variant(return_value, &v, obj->code_page TSRMLS_CC);
@@ -76,7 +76,7 @@ static void com_property_write(zval *object, zval *member, zval *value TSRMLS_DC
convert_to_string_ex(&member);
if (SUCCESS == php_com_do_invoke(obj, Z_STRVAL_P(member), Z_STRLEN_P(member),
- DISPATCH_PROPERTYPUT, &v, 1, &value TSRMLS_CC)) {
+ DISPATCH_PROPERTYPUT|DISPATCH_PROPERTYPUTREF, &v, 1, &value, 0 TSRMLS_CC)) {
VariantClear(&v);
}
} else {
@@ -101,7 +101,7 @@ static zval *com_read_dimension(zval *object, zval *offset, int type TSRMLS_DC)
VariantInit(&v);
if (SUCCESS == php_com_do_invoke_by_id(obj, DISPID_VALUE,
- DISPATCH_METHOD|DISPATCH_PROPERTYGET, &v, 1, &offset, 0 TSRMLS_CC)) {
+ DISPATCH_METHOD|DISPATCH_PROPERTYGET, &v, 1, &offset, 0, 0 TSRMLS_CC)) {
php_com_zval_from_variant(return_value, &v, obj->code_page TSRMLS_CC);
VariantClear(&v);
}
@@ -140,7 +140,7 @@ static void com_write_dimension(zval *object, zval *offset, zval *value TSRMLS_D
VariantInit(&v);
if (SUCCESS == php_com_do_invoke_by_id(obj, DISPID_VALUE,
- DISPATCH_METHOD|DISPATCH_PROPERTYPUT, &v, 2, args, 0 TSRMLS_CC)) {
+ DISPATCH_METHOD|DISPATCH_PROPERTYPUT, &v, 2, args, 0, 0 TSRMLS_CC)) {
VariantClear(&v);
}
} else if (V_ISARRAY(&obj->v)) {
@@ -499,7 +499,7 @@ static int com_object_cast(zval *readobj, zval *writeobj, int type TSRMLS_DC)
if (V_VT(&obj->v) == VT_DISPATCH) {
if (SUCCESS != php_com_do_invoke_by_id(obj, DISPID_VALUE,
- DISPATCH_METHOD|DISPATCH_PROPERTYGET, &v, 0, NULL, 1 TSRMLS_CC)) {
+ DISPATCH_METHOD|DISPATCH_PROPERTYGET, &v, 0, NULL, 1, 0 TSRMLS_CC)) {
VariantCopy(&v, &obj->v);
}
} else {
@@ -664,6 +664,7 @@ zend_object_value php_com_object_new(zend_class_entry *ce TSRMLS_DC)
php_com_dotnet_object *obj;
zend_object_value retval;
+ php_com_initialize(TSRMLS_C);
obj = emalloc(sizeof(*obj));
memset(obj, 0, sizeof(*obj));
diff --git a/ext/com_dotnet/com_iterator.c b/ext/com_dotnet/com_iterator.c
index 8756b4f4d..90ab03ef1 100644
--- a/ext/com_dotnet/com_iterator.c
+++ b/ext/com_dotnet/com_iterator.c
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2006 The PHP Group |
+ | Copyright (c) 1997-2007 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: com_iterator.c,v 1.9.2.2.2.1 2006/05/10 14:39:10 rrichards Exp $ */
+/* $Id: com_iterator.c,v 1.9.2.2.2.2 2007/01/01 09:35:48 sebastian Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
diff --git a/ext/com_dotnet/com_misc.c b/ext/com_dotnet/com_misc.c
index c3355ad8a..7ee866f98 100644
--- a/ext/com_dotnet/com_misc.c
+++ b/ext/com_dotnet/com_misc.c
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2006 The PHP Group |
+ | Copyright (c) 1997-2007 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: com_misc.c,v 1.8.2.2 2006/01/01 12:50:00 sniper Exp $ */
+/* $Id: com_misc.c,v 1.8.2.2.2.3 2007/02/02 15:44:06 wharmby Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -78,8 +78,9 @@ PHPAPI void php_com_wrap_variant(zval *z, VARIANT *v,
VariantInit(&obj->v);
VariantCopyInd(&obj->v, v);
+ obj->modified = 0;
- if (V_VT(&obj->v) == VT_DISPATCH) {
+ if ((V_VT(&obj->v) == VT_DISPATCH) && (V_DISPATCH(&obj->v) != NULL)) {
IDispatch_GetTypeInfo(V_DISPATCH(&obj->v), 0, LANG_NEUTRAL, &obj->typeinfo);
}
diff --git a/ext/com_dotnet/com_olechar.c b/ext/com_dotnet/com_olechar.c
index 258dcbc0c..651166537 100644
--- a/ext/com_dotnet/com_olechar.c
+++ b/ext/com_dotnet/com_olechar.c
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2006 The PHP Group |
+ | Copyright (c) 1997-2007 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: com_olechar.c,v 1.5.2.1 2006/01/01 12:50:00 sniper Exp $ */
+/* $Id: com_olechar.c,v 1.5.2.1.2.3 2007/02/21 01:13:44 stas Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -44,8 +44,8 @@ PHPAPI OLECHAR *php_com_string_to_olestring(char *string, uint string_len, int c
string_len++;
}
- if (strlen > 0) {
- olestring = (OLECHAR*)safe_emalloc(sizeof(OLECHAR), string_len, 0);
+ if (string_len > 0) {
+ olestring = (OLECHAR*)safe_emalloc(string_len, sizeof(OLECHAR), 0);
ok = MultiByteToWideChar(codepage, flags, string, string_len, olestring, string_len);
} else {
ok = FALSE;
@@ -75,7 +75,7 @@ PHPAPI char *php_com_olestring_to_string(OLECHAR *olestring, uint *string_len, i
length = WideCharToMultiByte(codepage, 0, olestring, -1, NULL, 0, NULL, NULL);
if (length) {
- string = (char*)safe_emalloc(sizeof(char), length, 0);
+ string = (char*)safe_emalloc(length, sizeof(char), 0);
length = WideCharToMultiByte(codepage, 0, olestring, -1, string, length, NULL, NULL);
ok = length > 0;
} else {
diff --git a/ext/com_dotnet/com_persist.c b/ext/com_dotnet/com_persist.c
index e53b86c23..49a21651e 100755
--- a/ext/com_dotnet/com_persist.c
+++ b/ext/com_dotnet/com_persist.c
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2006 The PHP Group |
+ | Copyright (c) 1997-2007 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: com_persist.c,v 1.5.2.3.2.1 2006/09/16 18:10:32 iliaa Exp $ */
+/* $Id: com_persist.c,v 1.5.2.3.2.2 2007/01/01 09:35:48 sebastian Exp $ */
/* Infrastructure for working with persistent COM objects.
* Implements: IStream* wrapper for PHP streams.
diff --git a/ext/com_dotnet/com_saproxy.c b/ext/com_dotnet/com_saproxy.c
index a985be0fc..c08ee5b3a 100644
--- a/ext/com_dotnet/com_saproxy.c
+++ b/ext/com_dotnet/com_saproxy.c
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2006 The PHP Group |
+ | Copyright (c) 1997-2007 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: com_saproxy.c,v 1.15.2.2.2.1 2006/05/10 14:39:10 rrichards Exp $ */
+/* $Id: com_saproxy.c,v 1.15.2.2.2.3 2007/01/01 09:35:48 sebastian Exp $ */
/* This module implements a SafeArray proxy which is used internally
* by the engine when resolving multi-dimensional array accesses on
@@ -120,7 +120,7 @@ static zval *saproxy_read_dimension(zval *object, zval *offset, int type TSRMLS_
res = php_com_do_invoke(proxy->obj, Z_STRVAL_P(proxy->indices[0]),
Z_STRLEN_P(proxy->indices[0]), DISPATCH_METHOD|DISPATCH_PROPERTYGET, &v,
- proxy->dimensions, args TSRMLS_CC);
+ proxy->dimensions, args, 0 TSRMLS_CC);
if (res == SUCCESS) {
php_com_zval_from_variant(return_value, &v, proxy->obj->code_page TSRMLS_CC);
@@ -233,7 +233,7 @@ static void saproxy_write_dimension(zval *object, zval *offset, zval *value TSRM
VariantInit(&v);
if (SUCCESS == php_com_do_invoke(proxy->obj, Z_STRVAL_P(proxy->indices[0]),
Z_STRLEN_P(proxy->indices[0]), DISPATCH_PROPERTYPUT, &v, proxy->dimensions + 1,
- args TSRMLS_CC)) {
+ args, 0 TSRMLS_CC)) {
VariantClear(&v);
}
diff --git a/ext/com_dotnet/com_typeinfo.c b/ext/com_dotnet/com_typeinfo.c
index a62e32df2..25ac81c96 100644
--- a/ext/com_dotnet/com_typeinfo.c
+++ b/ext/com_dotnet/com_typeinfo.c
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2006 The PHP Group |
+ | Copyright (c) 1997-2007 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: com_typeinfo.c,v 1.7.2.1.2.1 2006/08/25 12:01:57 edink Exp $ */
+/* $Id: com_typeinfo.c,v 1.7.2.1.2.3 2007/01/01 09:35:48 sebastian Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -220,8 +220,8 @@ PHPAPI int php_com_import_typelib(ITypeLib *TL, int mode, int codepage TSRMLS_DC
/* Type-library stuff */
void php_com_typelibrary_dtor(void *pDest)
{
- ITypeLib *Lib = (ITypeLib*)pDest;
- ITypeLib_Release(Lib);
+ ITypeLib **Lib = (ITypeLib**)pDest;
+ ITypeLib_Release(*Lib);
}
PHPAPI ITypeLib *php_com_load_typelib_via_cache(char *search_string,
@@ -249,7 +249,7 @@ PHPAPI ITypeLib *php_com_load_typelib_via_cache(char *search_string,
if (TL) {
if (SUCCESS == zend_ts_hash_update(&php_com_typelibraries,
- search_string, l+1, (void*)TL, sizeof(ITypeLib*), NULL)) {
+ search_string, l+1, (void*)&TL, sizeof(ITypeLib*), NULL)) {
/* add a reference for the hash table */
ITypeLib_AddRef(TL);
}
diff --git a/ext/com_dotnet/com_variant.c b/ext/com_dotnet/com_variant.c
index 59ffa9687..b60463b78 100644
--- a/ext/com_dotnet/com_variant.c
+++ b/ext/com_dotnet/com_variant.c
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2006 The PHP Group |
+ | Copyright (c) 1997-2007 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: com_variant.c,v 1.11.2.2 2006/02/04 10:57:27 rrichards Exp $ */
+/* $Id: com_variant.c,v 1.11.2.2.2.6 2007/04/09 15:32:35 dmitry Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -257,6 +257,140 @@ PHPAPI int php_com_zval_from_variant(zval *z, VARIANT *v, int codepage TSRMLS_DC
return ret;
}
+
+PHPAPI int php_com_copy_variant(VARIANT *dstvar, VARIANT *srcvar TSRMLS_DC)
+{
+ int ret = SUCCESS;
+
+ switch (V_VT(dstvar) & ~VT_BYREF) {
+ case VT_EMPTY:
+ case VT_NULL:
+ case VT_VOID:
+ /* should not be possible */
+ break;
+
+ case VT_UI1:
+ if (V_VT(dstvar) & VT_BYREF) {
+ *V_UI1REF(dstvar) = V_UI1(srcvar);
+ } else {
+ V_UI1(dstvar) = V_UI1(srcvar);
+ }
+ break;
+
+ case VT_I1:
+ if (V_VT(dstvar) & VT_BYREF) {
+ *V_I1REF(dstvar) = V_I1(srcvar);
+ } else {
+ V_I1(dstvar) = V_I1(srcvar);
+ }
+ break;
+
+ case VT_UI2:
+ if (V_VT(dstvar) & VT_BYREF) {
+ *V_UI2REF(dstvar) = V_UI2(srcvar);
+ } else {
+ V_UI2(dstvar) = V_UI2(srcvar);
+ }
+ break;
+
+ case VT_I2:
+ if (V_VT(dstvar) & VT_BYREF) {
+ *V_I2REF(dstvar) = V_I2(srcvar);
+ } else {
+ V_I2(dstvar) = V_I2(srcvar);
+ }
+ break;
+
+ case VT_UI4:
+ if (V_VT(dstvar) & VT_BYREF) {
+ *V_UI4REF(dstvar) = V_UI4(srcvar);
+ } else {
+ V_UI4(dstvar) = V_UI4(srcvar);
+ }
+ break;
+
+ case VT_I4:
+ if (V_VT(dstvar) & VT_BYREF) {
+ *V_I4REF(dstvar) = V_I4(srcvar);
+ } else {
+ V_I4(dstvar) = V_I4(srcvar);
+ }
+ break;
+
+ case VT_INT:
+ if (V_VT(dstvar) & VT_BYREF) {
+ *V_INTREF(dstvar) = V_INT(srcvar);
+ } else {
+ V_INT(dstvar) = V_INT(srcvar);
+ }
+ break;
+
+ case VT_UINT:
+ if (V_VT(dstvar) & VT_BYREF) {
+ *V_UINTREF(dstvar) = V_UINT(srcvar);
+ } else {
+ V_UINT(dstvar) = V_UINT(srcvar);
+ }
+ break;
+
+ case VT_R4:
+ if (V_VT(dstvar) & VT_BYREF) {
+ *V_R4REF(dstvar) = V_R4(srcvar);
+ } else {
+ V_R4(dstvar) = V_R4(srcvar);
+ }
+ break;
+
+ case VT_R8:
+ if (V_VT(dstvar) & VT_BYREF) {
+ *V_R8REF(dstvar) = V_R8(srcvar);
+ } else {
+ V_R8(dstvar) = V_R8(srcvar);
+ }
+ break;
+
+ case VT_BOOL:
+ if (V_VT(dstvar) & VT_BYREF) {
+ *V_BOOLREF(dstvar) = V_BOOL(srcvar);
+ } else {
+ V_BOOL(dstvar) = V_BOOL(srcvar);
+ }
+ break;
+
+ case VT_BSTR:
+ if (V_VT(dstvar) & VT_BYREF) {
+ *V_BSTRREF(dstvar) = V_BSTR(srcvar);
+ } else {
+ V_BSTR(dstvar) = V_BSTR(srcvar);
+ }
+ break;
+
+ case VT_UNKNOWN:
+ if (V_VT(dstvar) & VT_BYREF) {
+ *V_UNKNOWNREF(dstvar) = V_UNKNOWN(srcvar);
+ } else {
+ V_UNKNOWN(dstvar) = V_UNKNOWN(srcvar);
+ }
+ break;
+
+ case VT_DISPATCH:
+ if (V_VT(dstvar) & VT_BYREF) {
+ *V_DISPATCHREF(dstvar) = V_DISPATCH(srcvar);
+ } else {
+ V_DISPATCH(dstvar) = V_DISPATCH(srcvar);
+ }
+ break;
+
+ case VT_VARIANT:
+ return php_com_copy_variant(V_VARIANTREF(dstvar), srcvar TSRMLS_CC);
+
+ default:
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "variant->variant: failed to copy from 0x%x to 0x%x", V_VT(dstvar), V_VT(srcvar));
+ ret = FAILURE;
+ }
+ return ret;
+}
+
/* {{{ com_variant_create_instance - ctor for new VARIANT() */
PHP_FUNCTION(com_variant_create_instance)
{
@@ -280,6 +414,7 @@ PHP_FUNCTION(com_variant_create_instance)
return;
}
+ php_com_initialize(TSRMLS_C);
if (ZEND_NUM_ARGS() == 3) {
obj->code_page = codepage;
}
@@ -288,19 +423,36 @@ PHP_FUNCTION(com_variant_create_instance)
php_com_variant_from_zval(&obj->v, zvalue, obj->code_page TSRMLS_CC);
}
- if (ZEND_NUM_ARGS() >= 2) {
+ /* Only perform conversion if variant not already of type passed */
+ if ((ZEND_NUM_ARGS() >= 2) && (vt != V_VT(&obj->v))) {
+
+ /* If already an array and VT_ARRAY is passed then:
+ - if only VT_ARRAY passed then do not perform a conversion
+ - if VT_ARRAY plus other type passed then perform conversion
+ but will probably fail (origional behavior)
+ */
+ if ((vt & VT_ARRAY) && (V_VT(&obj->v) & VT_ARRAY)) {
+ long orig_vt = vt;
+
+ vt &= ~VT_ARRAY;
+ if (vt) {
+ vt = orig_vt;
+ }
+ }
- res = VariantChangeType(&obj->v, &obj->v, 0, (VARTYPE)vt);
+ if (vt) {
+ res = VariantChangeType(&obj->v, &obj->v, 0, (VARTYPE)vt);
- if (FAILED(res)) {
- char *werr, *msg;
+ if (FAILED(res)) {
+ char *werr, *msg;
- werr = php_win_err(res);
- spprintf(&msg, 0, "Variant type conversion failed: %s", werr);
- LocalFree(werr);
+ werr = php_win_err(res);
+ spprintf(&msg, 0, "Variant type conversion failed: %s", werr);
+ LocalFree(werr);
- php_com_throw_exception(res, msg TSRMLS_CC);
- efree(msg);
+ php_com_throw_exception(res, msg TSRMLS_CC);
+ efree(msg);
+ }
}
}
@@ -339,6 +491,8 @@ PHP_FUNCTION(variant_set)
VariantClear(&obj->v);
php_com_variant_from_zval(&obj->v, zvalue, obj->code_page TSRMLS_CC);
+ /* remember we modified this variant */
+ obj->modified = 1;
}
/* }}} */
@@ -789,6 +943,7 @@ PHP_FUNCTION(variant_date_to_timestamp)
PHP_FUNCTION(variant_date_from_timestamp)
{
long timestamp;
+ time_t ttstamp;
SYSTEMTIME systime;
struct tm *tmv;
VARIANT res;
@@ -798,9 +953,15 @@ PHP_FUNCTION(variant_date_from_timestamp)
return;
}
+ if (timestamp < 0) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Timestamp value must be a positive value.");
+ RETURN_FALSE;
+ }
+
VariantInit(&res);
tzset();
- tmv = localtime(&timestamp);
+ ttstamp = timestamp;
+ tmv = localtime(&ttstamp);
memset(&systime, 0, sizeof(systime));
systime.wDay = tmv->tm_mday;
diff --git a/ext/com_dotnet/com_wrapper.c b/ext/com_dotnet/com_wrapper.c
index 09c11677f..a9f9afd8f 100644
--- a/ext/com_dotnet/com_wrapper.c
+++ b/ext/com_dotnet/com_wrapper.c
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2006 The PHP Group |
+ | Copyright (c) 1997-2007 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: com_wrapper.c,v 1.9.2.1 2006/01/01 12:50:00 sniper Exp $ */
+/* $Id: com_wrapper.c,v 1.9.2.1.2.5 2007/03/05 15:49:00 wharmby Exp $ */
/* This module exports a PHP object as a COM object by wrapping it
* using IDispatchEx */
@@ -74,7 +74,7 @@ static inline void trace(char *fmt, ...)
va_list ap;
char buf[4096];
- sprintf(buf, "T=%08x ", GetCurrentThreadId());
+ snprintf(buf, sizeof(buf), "T=%08x ", GetCurrentThreadId());
OutputDebugString(buf);
va_start(ap, fmt);
@@ -92,13 +92,17 @@ static inline void trace(char *fmt, ...)
# define TSRMLS_FIXED()
#endif
-#define FETCH_DISP(methname) \
- TSRMLS_FIXED() \
- php_dispatchex *disp = (php_dispatchex*)This; \
- trace(" PHP:%s %s\n", Z_OBJCE_P(disp->object)->name, methname); \
- if (GetCurrentThreadId() != disp->engine_thread) \
- return RPC_E_WRONG_THREAD;
-
+#define FETCH_DISP(methname) \
+ TSRMLS_FIXED() \
+ php_dispatchex *disp = (php_dispatchex*)This; \
+ if (COMG(rshutdown_started)) { \
+ trace(" PHP Object:%p (name:unknown) %s\n", disp->object, methname); \
+ } else { \
+ trace(" PHP Object:%p (name:%s) %s\n", disp->object, Z_OBJCE_P(disp->object)->name, methname); \
+ } \
+ if (GetCurrentThreadId() != disp->engine_thread) { \
+ return RPC_E_WRONG_THREAD; \
+ }
static HRESULT STDMETHODCALLTYPE disp_queryinterface(
IDispatchEx *This,
@@ -298,6 +302,17 @@ static HRESULT STDMETHODCALLTYPE disp_invokeex(
&retval, pdp->cArgs, params, 1, NULL TSRMLS_CC)) {
ret = S_OK;
trace("function called ok\n");
+
+ /* Copy any modified values to callers copy of variant*/
+ for (i = 0; i < pdp->cArgs; i++) {
+ php_com_dotnet_object *obj = CDNO_FETCH(*params[i]);
+ VARIANT *srcvar = &obj->v;
+ VARIANT *dstvar = &pdp->rgvarg[ pdp->cArgs - 1 - i];
+ if ((V_VT(dstvar) & VT_BYREF) && obj->modified ) {
+ trace("percolate modified value for arg %d VT=%08x\n", i, V_VT(dstvar));
+ php_com_copy_variant(dstvar, srcvar TSRMLS_CC);
+ }
+ }
} else {
trace("failed to call func\n");
ret = DISP_E_EXCEPTION;
@@ -463,7 +478,7 @@ static void generate_dispids(php_dispatchex *disp TSRMLS_DC)
&namelen, &pid, 0, &pos))) {
char namebuf[32];
if (keytype == HASH_KEY_IS_LONG) {
- sprintf(namebuf, "%d", pid);
+ snprintf(namebuf, sizeof(namebuf), "%d", pid);
name = namebuf;
namelen = strlen(namebuf)+1;
}
@@ -477,6 +492,7 @@ static void generate_dispids(php_dispatchex *disp TSRMLS_DC)
/* add the mappings */
MAKE_STD_ZVAL(tmp);
ZVAL_STRINGL(tmp, name, namelen-1, 1);
+ pid = zend_hash_next_free_element(disp->dispid_to_name);
zend_hash_index_update(disp->dispid_to_name, pid, (void*)&tmp, sizeof(zval *), NULL);
MAKE_STD_ZVAL(tmp);
@@ -494,7 +510,7 @@ static void generate_dispids(php_dispatchex *disp TSRMLS_DC)
char namebuf[32];
if (keytype == HASH_KEY_IS_LONG) {
- sprintf(namebuf, "%d", pid);
+ snprintf(namebuf, sizeof(namebuf), "%d", pid);
name = namebuf;
namelen = strlen(namebuf) + 1;
}
@@ -508,6 +524,7 @@ static void generate_dispids(php_dispatchex *disp TSRMLS_DC)
/* add the mappings */
MAKE_STD_ZVAL(tmp);
ZVAL_STRINGL(tmp, name, namelen-1, 1);
+ pid = zend_hash_next_free_element(disp->dispid_to_name);
zend_hash_index_update(disp->dispid_to_name, pid, (void*)&tmp, sizeof(zval *), NULL);
MAKE_STD_ZVAL(tmp);
@@ -521,7 +538,7 @@ static php_dispatchex *disp_constructor(zval *object TSRMLS_DC)
{
php_dispatchex *disp = (php_dispatchex*)CoTaskMemAlloc(sizeof(php_dispatchex));
- trace("constructing a COM proxy\n");
+ trace("constructing a COM wrapper for PHP object %p (%s)\n", object, Z_OBJCE_P(object)->name);
if (disp == NULL)
return NULL;
@@ -546,8 +563,13 @@ static void disp_destructor(php_dispatchex *disp)
{
TSRMLS_FETCH();
- trace("destroying COM wrapper for PHP object %s\n", Z_OBJCE_P(disp->object)->name);
-
+ /* Object store not available during request shutdown */
+ if (COMG(rshutdown_started)) {
+ trace("destroying COM wrapper for PHP object %p (name:unknown)\n", disp->object);
+ } else {
+ trace("destroying COM wrapper for PHP object %p (name:%s)\n", disp->object, Z_OBJCE_P(disp->object)->name);
+ }
+
disp->id = 0;
if (disp->refcount > 0)
diff --git a/ext/com_dotnet/package.xml b/ext/com_dotnet/package.xml
index f9976245a..2839447bb 100644
--- a/ext/com_dotnet/package.xml
+++ b/ext/com_dotnet/package.xml
@@ -20,7 +20,7 @@
<version>5.0.0rc1</version>
<date>2004-03-19</date>
<notes>
-package.xml added to support intallation using pear installer
+package.xml added to support installation using pear installer
</notes>
<filelist>
<file role="doc" name="CREDITS"/>
diff --git a/ext/com_dotnet/php_com_dotnet.h b/ext/com_dotnet/php_com_dotnet.h
index d85db555a..d0f8d3c9f 100644
--- a/ext/com_dotnet/php_com_dotnet.h
+++ b/ext/com_dotnet/php_com_dotnet.h
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2006 The PHP Group |
+ | Copyright (c) 1997-2007 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_com_dotnet.h,v 1.5.2.1 2006/01/01 12:50:00 sniper Exp $ */
+/* $Id: php_com_dotnet.h,v 1.5.2.1.2.2 2007/03/05 15:49:00 wharmby Exp $ */
#ifndef PHP_COM_DOTNET_H
#define PHP_COM_DOTNET_H
@@ -47,6 +47,7 @@ ZEND_BEGIN_MODULE_GLOBALS(com_dotnet)
zend_bool autoreg_case_sensitive;
void *dotnet_runtime_stuff; /* opaque to avoid cluttering up other modules */
int code_page; /* default code_page if left unspecified */
+ zend_bool rshutdown_started;
ZEND_END_MODULE_GLOBALS(com_dotnet)
#ifdef ZTS
diff --git a/ext/com_dotnet/php_com_dotnet_internal.h b/ext/com_dotnet/php_com_dotnet_internal.h
index b63ecb2b9..ba8dbf642 100644
--- a/ext/com_dotnet/php_com_dotnet_internal.h
+++ b/ext/com_dotnet/php_com_dotnet_internal.h
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2006 The PHP Group |
+ | Copyright (c) 1997-2007 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_com_dotnet_internal.h,v 1.14.2.3.2.1 2006/05/10 14:39:10 rrichards Exp $ */
+/* $Id: php_com_dotnet_internal.h,v 1.14.2.3.2.4 2007/02/02 15:27:35 wharmby Exp $ */
#ifndef PHP_COM_DOTNET_INTERNAL_H
#define PHP_COM_DOTNET_INTERNAL_H
@@ -36,6 +36,7 @@ typedef struct _php_com_dotnet_object {
zend_object zo;
VARIANT v;
+ int modified;
ITypeInfo *typeinfo;
long code_page;
@@ -102,13 +103,13 @@ PHP_FUNCTION(com_load_typelib);
PHP_FUNCTION(com_get_active_object);
HRESULT php_com_invoke_helper(php_com_dotnet_object *obj, DISPID id_member,
- WORD flags, DISPPARAMS *disp_params, VARIANT *v, int silent TSRMLS_DC);
+ WORD flags, DISPPARAMS *disp_params, VARIANT *v, int silent, int allow_noarg TSRMLS_DC);
HRESULT php_com_get_id_of_name(php_com_dotnet_object *obj, char *name,
int namelen, DISPID *dispid TSRMLS_DC);
int php_com_do_invoke_by_id(php_com_dotnet_object *obj, DISPID dispid,
- WORD flags, VARIANT *v, int nargs, zval **args, int silent TSRMLS_DC);
+ WORD flags, VARIANT *v, int nargs, zval **args, int silent, int allow_noarg TSRMLS_DC);
int php_com_do_invoke(php_com_dotnet_object *obj, char *name, int namelen,
- WORD flags, VARIANT *v, int nargs, zval **args TSRMLS_DC);
+ WORD flags, VARIANT *v, int nargs, zval **args, int allow_noarg TSRMLS_DC);
int php_com_do_invoke_byref(php_com_dotnet_object *obj, char *name, int namelen,
WORD flags, VARIANT *v, int nargs, zval ***args TSRMLS_DC);
@@ -152,6 +153,7 @@ PHP_FUNCTION(variant_cast);
PHPAPI void php_com_variant_from_zval_with_type(VARIANT *v, zval *z, VARTYPE type, int codepage TSRMLS_DC);
PHPAPI void php_com_variant_from_zval(VARIANT *v, zval *z, int codepage TSRMLS_DC);
PHPAPI int php_com_zval_from_variant(zval *z, VARIANT *v, int codepage TSRMLS_DC);
+PHPAPI int php_com_copy_variant(VARIANT *dst, VARIANT *src TSRMLS_DC);
/* com_dotnet.c */
PHP_FUNCTION(com_dotnet_create_instance);
diff --git a/ext/com_dotnet/tests/bug33386.phpt b/ext/com_dotnet/tests/bug33386.phpt
new file mode 100644
index 000000000..e57f1274c
--- /dev/null
+++ b/ext/com_dotnet/tests/bug33386.phpt
@@ -0,0 +1,40 @@
+--TEST--
+Bug #33386 (ScriptControl only sees last function of class)
+--SKIPIF--
+<?php
+if (!extension_loaded("com_dotnet")) print "skip COM/.Net support not present"; ?>
+--FILE--
+<?php
+error_reporting(E_ALL);
+
+class twoFuncs {
+ public function func1() { echo " func one\n"; }
+ public function func2() { echo " func two\n"; }
+}
+
+try {
+ $ciTF = new twoFuncs;
+
+ $oScript = new COM("MSScriptControl.ScriptControl");
+ $oScript->Language = "VBScript";
+
+ $oScript->AddObject ("tfA", $ciTF, true);
+ foreach (array(1,2) as $i) {
+ $oScript->ExecuteStatement ("tfA.func$i");
+ $oScript->ExecuteStatement ("func$i");
+ }
+ $oScript->AddObject ("tfB", $ciTF);
+ foreach (array(1,2) as $i) {
+ $oScript->ExecuteStatement ("tfB.func$i");
+ }
+} catch (Exception $e) {
+ print $e;
+}
+?>
+--EXPECT--
+ func one
+ func one
+ func two
+ func two
+ func one
+ func two
diff --git a/ext/com_dotnet/tests/bug39596.phpt b/ext/com_dotnet/tests/bug39596.phpt
new file mode 100644
index 000000000..dc8d1ef06
--- /dev/null
+++ b/ext/com_dotnet/tests/bug39596.phpt
@@ -0,0 +1,23 @@
+--TEST--
+Bug #39596 (Creating Variant of type VT_ARRAY)
+--SKIPIF--
+<?php
+if (!extension_loaded("com_dotnet")) print "skip COM/.Net support not present"; ?>
+--FILE--
+<?php
+error_reporting(E_ALL);
+
+try {
+ $binding_string = array('aaa','bbb','ccc');
+ $v = new VARIANT( $binding_string, VT_ARRAY );
+ foreach ($v AS $element) {
+ print $element."\n";
+ }
+} catch (Exception $e) {
+ print $e;
+}
+?>
+--EXPECT--
+aaa
+bbb
+ccc
diff --git a/ext/com_dotnet/tests/bug39606.phpt b/ext/com_dotnet/tests/bug39606.phpt
new file mode 100644
index 000000000..07ebef3bd
--- /dev/null
+++ b/ext/com_dotnet/tests/bug39606.phpt
@@ -0,0 +1,22 @@
+--TEST--
+COM: Loading typelib corrupts memory
+--SKIPIF--
+<?php # vim:ft=php
+if (!extension_loaded("com_dotnet")) print "skip COM/.Net support not present"; ?>
+--FILE--
+<?php // $Id: bug39606.phpt,v 1.1.2.1 2006/12/09 10:52:09 rrichards Exp $
+error_reporting(E_ALL);
+
+$arEnv = array_change_key_case($_SERVER, CASE_UPPER);
+
+$root = dirname($arEnv['COMSPEC']);
+$typelib = $root.'\activeds.tlb';
+
+var_dump(com_load_typelib($typelib));
+var_dump(com_load_typelib($typelib));
+?>
+===DONE===
+--EXPECT--
+bool(true)
+bool(true)
+===DONE=== \ No newline at end of file