summaryrefslogtreecommitdiff
path: root/ext/com_dotnet
diff options
context:
space:
mode:
authorRob Richards <rrichards@php.net>2005-11-27 12:21:12 +0000
committerRob Richards <rrichards@php.net>2005-11-27 12:21:12 +0000
commit93ee6cd53313dc3e259c24aa936eb89b2e882cec (patch)
tree887e63e0d916429bec2ba0c92ebebbe353f7d6ab /ext/com_dotnet
parent1bec704ea7bddb276873408646ec2e8fc2c52526 (diff)
downloadphp-git-93ee6cd53313dc3e259c24aa936eb89b2e882cec.tar.gz
Fixed bug #35316 (Application exception trying to create COM object)
Fix some handler signatures causing memory corruption Various unicode fixes
Diffstat (limited to 'ext/com_dotnet')
-rw-r--r--ext/com_dotnet/com_handlers.c11
-rw-r--r--ext/com_dotnet/com_misc.c4
-rw-r--r--ext/com_dotnet/com_saproxy.c4
-rw-r--r--ext/com_dotnet/com_variant.c8
-rw-r--r--ext/com_dotnet/php_com_dotnet_internal.h2
5 files changed, 16 insertions, 13 deletions
diff --git a/ext/com_dotnet/com_handlers.c b/ext/com_dotnet/com_handlers.c
index c53c11808a..7b55b1e33e 100644
--- a/ext/com_dotnet/com_handlers.c
+++ b/ext/com_dotnet/com_handlers.c
@@ -486,17 +486,13 @@ static int com_objects_compare(zval *object1, zval *object2 TSRMLS_DC)
return ret;
}
-static int com_object_cast(zval *readobj, zval *writeobj, int type, int should_free TSRMLS_DC)
+static int com_object_cast(zval *readobj, zval *writeobj, int type TSRMLS_DC)
{
php_com_dotnet_object *obj;
VARIANT v;
VARTYPE vt = VT_EMPTY;
zval free_obj;
HRESULT res = S_OK;
-
- if (should_free) {
- free_obj = *writeobj;
- }
obj = CDNO_FETCH(readobj);
ZVAL_NULL(writeobj);
@@ -539,10 +535,6 @@ static int com_object_cast(zval *readobj, zval *writeobj, int type, int should_f
VariantClear(&v);
- if (should_free) {
- zval_dtor(&free_obj);
- }
-
if (SUCCEEDED(res)) {
return SUCCESS;
}
@@ -678,6 +670,7 @@ zend_object_value php_com_object_new(zend_class_entry *ce TSRMLS_DC)
VariantInit(&obj->v);
obj->code_page = CP_ACP;
obj->ce = ce;
+ obj->zo.ce = ce;
retval.handle = zend_objects_store_put(obj, NULL, php_com_object_free_storage, php_com_object_clone TSRMLS_CC);
retval.handlers = &php_com_object_handlers;
diff --git a/ext/com_dotnet/com_misc.c b/ext/com_dotnet/com_misc.c
index bee9c7dcf8..f14f30e337 100644
--- a/ext/com_dotnet/com_misc.c
+++ b/ext/com_dotnet/com_misc.c
@@ -36,7 +36,7 @@ void php_com_throw_exception(HRESULT code, char *message TSRMLS_DC)
message = php_win_err(code);
free_msg = 1;
}
- zend_throw_exception(php_com_exception_class_entry, message, (long)code TSRMLS_CC);
+ zend_throw_exception(U_CLASS_ENTRY(php_com_exception_class_entry), message, (long)code TSRMLS_CC);
if (free_msg) {
LocalFree(message);
}
@@ -51,6 +51,7 @@ PHPAPI void php_com_wrap_dispatch(zval *z, IDispatch *disp,
memset(obj, 0, sizeof(*obj));
obj->code_page = codepage;
obj->ce = php_com_variant_class_entry;
+ obj->zo.ce = php_com_variant_class_entry;
VariantInit(&obj->v);
V_VT(&obj->v) = VT_DISPATCH;
@@ -73,6 +74,7 @@ PHPAPI void php_com_wrap_variant(zval *z, VARIANT *v,
memset(obj, 0, sizeof(*obj));
obj->code_page = codepage;
obj->ce = php_com_variant_class_entry;
+ obj->zo.ce = php_com_variant_class_entry;
VariantInit(&obj->v);
VariantCopyInd(&obj->v, v);
diff --git a/ext/com_dotnet/com_saproxy.c b/ext/com_dotnet/com_saproxy.c
index 15b217fa68..9237f69c85 100644
--- a/ext/com_dotnet/com_saproxy.c
+++ b/ext/com_dotnet/com_saproxy.c
@@ -323,7 +323,7 @@ static HashTable *saproxy_properties_get(zval *object TSRMLS_DC)
return NULL;
}
-static union _zend_function *saproxy_method_get(zval *object, char *name, int len TSRMLS_DC)
+static union _zend_function *saproxy_method_get(zval **object, char *name, int len TSRMLS_DC)
{
/* no methods */
return NULL;
@@ -357,7 +357,7 @@ static int saproxy_objects_compare(zval *object1, zval *object2 TSRMLS_DC)
return -1;
}
-static int saproxy_object_cast(zval *readobj, zval *writeobj, int type, int should_free TSRMLS_DC)
+static int saproxy_object_cast(zval *readobj, zval *writeobj, int type TSRMLS_DC)
{
return FAILURE;
}
diff --git a/ext/com_dotnet/com_variant.c b/ext/com_dotnet/com_variant.c
index 7c3ea12c5a..573237d370 100644
--- a/ext/com_dotnet/com_variant.c
+++ b/ext/com_dotnet/com_variant.c
@@ -217,7 +217,13 @@ PHPAPI int php_com_zval_from_variant(zval *z, VARIANT *v, int codepage TSRMLS_DC
break;
case VT_BSTR:
if (V_BSTR(v)) {
- ZVAL_UNICODE(z, V_BSTR(v), 1);
+ if (UG(unicode)) {
+ ZVAL_UNICODE(z, V_BSTR(v), 1);
+ } else {
+ Z_TYPE_P(z) = IS_STRING;
+ Z_STRVAL_P(z) = php_com_olestring_to_string(V_BSTR(v),
+ &Z_STRLEN_P(z), codepage TSRMLS_CC);
+ }
}
break;
case VT_UNKNOWN:
diff --git a/ext/com_dotnet/php_com_dotnet_internal.h b/ext/com_dotnet/php_com_dotnet_internal.h
index 35b0410f4e..19fc806233 100644
--- a/ext/com_dotnet/php_com_dotnet_internal.h
+++ b/ext/com_dotnet/php_com_dotnet_internal.h
@@ -33,6 +33,8 @@
#undef php_win_err
typedef struct _php_com_dotnet_object {
+ zend_object zo;
+
VARIANT v;
ITypeInfo *typeinfo;