php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #10671 Cannot retrieve secondary object properties
Submitted: 2001-05-04 12:33 UTC Modified: 2001-05-07 13:27 UTC
From: sasha at tarkvara dot com Assigned:
Status: Closed Package: COM related
PHP Version: 4.0.5 OS: Windows 2000
Private report: No CVE-ID: None
 [2001-05-04 12:33 UTC] sasha at tarkvara dot com
The following code causes PHP to die at line 3:
$mgr = new COM("Factory");
$child = $mgr->GetChild(1);
echo $child->Attribute;

($mgr's method GetChild returns a COM object, which
has property 'Attribute').

The bug is in php_variant_to_pval() function in 
ext/com/conversion.c, line 501:
 handle->value.lval = zend_list_insert(var_arg->pdispVal, php_COM_get_le_idispatch());

it saves raw interface pointer var_arg->pdispVal, whereas everywhere else it is expected that the list contains i_dispatch pointer.

The line should be replaced with 
 i_dispatch *obj = (i_dispatch *)emalloc(sizeof(*obj));
 php_COM_set(obj,var_arg->pdispVal,FALSE); // not sure whether the last parameter should be TRUE or FALSE
 handle->value.lval = zend_list_insert(obj, php_COM_get_le_idispatch());
 

Also, the code in php_COM_set is somewhat bizarre:
- the returned value (hr) will not be set if cleanup is FALSE
- pDisp is unnecessarily cleared if cleanup is FALSE (it's a parameter, and it's not used afterwards).

Also, I am not sure that reference counting for COM objects is correct.

Also, please comment your code. It took me a day to find out this little bug.

Sasha

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-05-07 12:47 UTC] sbergmann@php.net
Does this problem persist with PHP 4.0.6-dev? There have been a lot of changes to ext/com recently, including improtant fixes after the PHP 4.0.5 release that will be included in PHP 4.0.6.

 [2001-05-07 13:16 UTC] sasha at tarkvara dot com
IT turns out this bug has been fixed in 
ext/com/conversion.c 1.8

Thanks
Sasha
 [2001-05-07 13:27 UTC] derick@php.net
user says it's fixed
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Thu Mar 21 01:01:30 2019 UTC