|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #29392 com_method_get() appears to not handle non-existant method properly
Submitted: 2004-07-26 18:56 UTC Modified: 2004-07-28 00:20 UTC
From: msisolak at yahoo dot com Assigned:
Status: Closed Package: COM related
PHP Version: 5.0.0 OS: Windows 2000 Professional
Private report: No CVE-ID: None
 [2004-07-26 18:56 UTC] msisolak at yahoo dot com
Trying to echo a COM object results in crash.

When zend_call_function() is called to lookup "__tostring" in a COM object, it calls into com_method_get().  In turn this calls ITypeComp_Bind to lookup the method.  If the method is not found the result is DESCKIND_NONE, but the switch(kind) statement isn't testing for this.  As a result com_method_get() returns a zend_internal_function with an invalid handler.  The handler is called and PHP crashes.

I came up with this possible code as the response to a DESCKIND_NONE:

	return NULL;

but I'm not too confident about it.  It does stop the crash in my test case, but there may be a better solution.

Reproduce code:
$c = new COM("ADODB.Connection");
echo $c;

Expected result:
Either error on trying to echo object with no __toString() method, or nothing.

Actual result:
The instruction at "0x00e5c208" referenced memory at "0x0000000".  The memory could not be "written".


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2004-07-27 04:02 UTC]
Fixed in HEAD; thanks for pointing out the error :-)

Actual Fix was:

 [2004-07-27 04:40 UTC]
Actually, this broke calling methods that are dynamically added at runtime.

Would you mind trying to debug this a bit more?
It sounds like the crash is somewhere else.
 [2004-07-28 00:20 UTC]

your sample still does not work (but does not crash) because the engine tries to call $c->__toString() and the ADODB object *might* implement that method, but doesn't know until you open the connection.

PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Fri Apr 26 08:01:25 2019 UTC