#23155 [NEW]: The COM interface can't support pass by reference
| From: | wanght at hotmail dot com | Date: | Thu, 10 Apr 2003 16:22:52 +0000 |
| Subject: | #23155 [NEW]: The COM interface can't support pass by reference | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-37528@lists.php.net to get a copy of this message | ||
From: wanght at hotmail dot com
Operating system: Window 2K English
PHP version: 4.3.1
PHP Bug Type: COM related
Bug description: The COM interface can't support pass by reference
I wrote a simple COM object using VC & ATL.
Here a part of code
HRESULT FetchValue([in, out]int* iValue, [out]int* iResult)
STDMETHODIMP CSimpleCom::FetchValue(int* iValue, int* iResult)
{
int iTemp = *iValue + 10;
*iValue = iTemp;
*iResult = iTemp;
return S_OK;
}
I wrote a PHP script to invoke this method. It can't get the new value
from this function.
<?php
echo "Call Com Object<br>";
$instance = new COM("comtest.SimpleCom");
$value = 15;
$result =10;
$instance->FetchValue(&$value, &$result);
echo "<b>Access function <i>void FetchValue(int*, int*):
</i></b>";
echo "Output result: ".$result."<br>";
echo "Output value: ".$value."<br>";
$instance->release();
?>
After reading the source code, I found the function php_pval_to_variant in
conversion.c didn't check if the variale is passed by reference. Am I
right? Maybe this is the problem.
By the way, this is a little bug in the COM interface function.
php_VARIANT_call_function_handler (VARIANT.c)
call function VariantInit(), and then call
php_pval_to_variant_ex(conversion.c) -->
php_pval_to_variant_ex2(conversion.c), the function VariantInit() has been
called again.
But in another invocation path
do_COM_invoke(COM.c) -> php_pval_to_variant(conversion.c) ->
php_pval_to_variant_ex2, the function VariantInit() is only invoked once.
--
Edit bug report at http://bugs.php.net/?id=23155&edit=1
--
Try a CVS snapshot: http://bugs.php.net/fix.php?id=23155&r=trysnapshot
Fixed in CVS: http://bugs.php.net/fix.php?id=23155&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=23155&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=23155&r=needtrace
Try newer version: http://bugs.php.net/fix.php?id=23155&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=23155&r=support
Expected behavior: http://bugs.php.net/fix.php?id=23155&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=23155&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=23155&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=23155&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=23155&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=23155&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=23155&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=23155&r=gnused