summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHarald Radi <phanto@php.net>2001-09-10 09:22:40 +0000
committerHarald Radi <phanto@php.net>2001-09-10 09:22:40 +0000
commitd1a2dbfd9dc005bb8b07ab63c7086978f71fd7c7 (patch)
tree41837215a0eac661591528895d38ddbe1dd59175
parent3b52256bd10f5af65da17bfb1f43a960c74a6f54 (diff)
downloadphp-git-d1a2dbfd9dc005bb8b07ab63c7086978f71fd7c7.tar.gz
IDispatchs got released if they were passed to another component
-rw-r--r--ext/com/COM.c12
-rw-r--r--ext/rpc/com/com_wrapper.c12
2 files changed, 22 insertions, 2 deletions
diff --git a/ext/com/COM.c b/ext/com/COM.c
index fda0b948da..b4d855242e 100644
--- a/ext/com/COM.c
+++ b/ext/com/COM.c
@@ -511,6 +511,12 @@ PHP_FUNCTION(com_load)
/* @todo if (server_name) */
if (!server_name) {
+ /* @todo shouldn't the bind context be fetched on module startup and kept as a global shared instance ?
+ * all calls to BindToObject would deliver the same instance then (as desired)
+ * IBindCtx::RegisterObjectBound() should be called then after mkparsedisplayname()
+ *
+ * @todo use mkparsedisplaynameex() ?
+ */
if (SUCCEEDED(hr = CreateBindCtx(0, &pBindCtx))) {
if (SUCCEEDED(hr = MkParseDisplayName(pBindCtx, ProgID, &ulEaten, &pMoniker))) {
hr = pMoniker->lpVtbl->BindToObject(pMoniker, pBindCtx, NULL, &IID_IDispatch, (LPVOID *) &C_DISPATCH(obj));
@@ -742,7 +748,11 @@ int do_COM_invoke(comval *obj, pval *function_name, VARIANT *var_result, pval **
efree(funcname);
for (current_arg=0;current_arg<arg_count;current_arg++) {
- VariantClear(&variant_args[current_arg]);
+ /* don't release IDispatch pointers as they are used afterwards */
+ if (V_VT(&variant_args[current_arg]) != VT_DISPATCH) {
+ /* @todo review this: what happens to an array of IDispatchs or a VARIANT->IDispatch */
+ VariantClear(&variant_args[current_arg]);
+ }
}
efree(variant_args);
diff --git a/ext/rpc/com/com_wrapper.c b/ext/rpc/com/com_wrapper.c
index fda0b948da..b4d855242e 100644
--- a/ext/rpc/com/com_wrapper.c
+++ b/ext/rpc/com/com_wrapper.c
@@ -511,6 +511,12 @@ PHP_FUNCTION(com_load)
/* @todo if (server_name) */
if (!server_name) {
+ /* @todo shouldn't the bind context be fetched on module startup and kept as a global shared instance ?
+ * all calls to BindToObject would deliver the same instance then (as desired)
+ * IBindCtx::RegisterObjectBound() should be called then after mkparsedisplayname()
+ *
+ * @todo use mkparsedisplaynameex() ?
+ */
if (SUCCEEDED(hr = CreateBindCtx(0, &pBindCtx))) {
if (SUCCEEDED(hr = MkParseDisplayName(pBindCtx, ProgID, &ulEaten, &pMoniker))) {
hr = pMoniker->lpVtbl->BindToObject(pMoniker, pBindCtx, NULL, &IID_IDispatch, (LPVOID *) &C_DISPATCH(obj));
@@ -742,7 +748,11 @@ int do_COM_invoke(comval *obj, pval *function_name, VARIANT *var_result, pval **
efree(funcname);
for (current_arg=0;current_arg<arg_count;current_arg++) {
- VariantClear(&variant_args[current_arg]);
+ /* don't release IDispatch pointers as they are used afterwards */
+ if (V_VT(&variant_args[current_arg]) != VT_DISPATCH) {
+ /* @todo review this: what happens to an array of IDispatchs or a VARIANT->IDispatch */
+ VariantClear(&variant_args[current_arg]);
+ }
}
efree(variant_args);