Skip to content

Commit

Permalink
Fix #64130: COM obj parameters passed by reference are not updated
Browse files Browse the repository at this point in the history
`ITypeInfo_GetIDsOfNames()` is supposed to fail with `E_NOTIMPL` for
out-of-process servers, thus we should not remove the already available
typeinfo of the object in this case.

We also properly free the `byref_vals`.
  • Loading branch information
cmb69 committed Aug 26, 2020
1 parent d179e34 commit 5ff15e2
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 1 deletion.
4 changes: 4 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ PHP NEWS
. Fixed bug #80007 (Potential type confusion in unixtojd() parameter parsing).
(Andy Postnikov)

- COM:
. Fixed bug #64130 (COM obj parameters passed by reference are not updated).
(cmb)

- OPcache:
. Fixed bug #80002 (calc free space for new interned string is wrong).
(t-matsuno)
Expand Down
4 changes: 3 additions & 1 deletion ext/com_dotnet/com_com.c
Original file line number Diff line number Diff line change
Expand Up @@ -439,8 +439,9 @@ HRESULT php_com_get_id_of_name(php_com_dotnet_object *obj, char *name,
if (obj->typeinfo) {
hr = ITypeInfo_GetIDsOfNames(obj->typeinfo, &olename, 1, dispid);
if (FAILED(hr)) {
HRESULT hr1 = hr;
hr = IDispatch_GetIDsOfNames(V_DISPATCH(&obj->v), &IID_NULL, &olename, 1, LOCALE_SYSTEM_DEFAULT, dispid);
if (SUCCEEDED(hr)) {
if (SUCCEEDED(hr) && hr1 != E_NOTIMPL) {
/* fall back on IDispatch direct */
ITypeInfo_Release(obj->typeinfo);
obj->typeinfo = NULL;
Expand Down Expand Up @@ -588,6 +589,7 @@ int php_com_do_invoke_byref(php_com_dotnet_object *obj, zend_internal_function *
}
}
efree(vargs);
if (byref_vals) efree(byref_vals);
}

return SUCCEEDED(hr) ? SUCCESS : FAILURE;
Expand Down
27 changes: 27 additions & 0 deletions ext/com_dotnet/tests/bug64130.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
--TEST--
Bug #64130 (COM obj parameters passed by reference are not updated)
--SKIPIF--
<?php
if (!extension_loaded('com_dotnet')) die('skip com_dotnet extension not available');
if (PHP_INT_SIZE != 4) die('skip for 32bit platforms only');
try {
$ie = new com('InternetExplorer.Application');
} catch (com_exception $ex) {
die("skip {$ex->getMessage()}");
}
$ie->quit();
?>
--FILE--
<?php
$ie = new com('InternetExplorer.Application');
$x = 0;
$y = 0;
try {
$ie->clientToWindow($x, $y);
} catch (com_exception $ex) {}
var_dump($x > 0, $y > 0);
$ie->quit();
?>
--EXPECT--
bool(true)
bool(true)

0 comments on commit 5ff15e2

Please sign in to comment.