diff options
| author | Wez Furlong <wez@php.net> | 2004-07-27 01:59:44 +0000 |
|---|---|---|
| committer | Wez Furlong <wez@php.net> | 2004-07-27 01:59:44 +0000 |
| commit | 20534bc4459860820cac2a2e97492e7ba3e6d731 (patch) | |
| tree | 80fe153082be30697245a4490c4258f54c252d21 | |
| parent | 03e298ec47b6c41d7681ee8fa221ebd20c274e93 (diff) | |
| download | php-git-20534bc4459860820cac2a2e97492e7ba3e6d731.tar.gz | |
Fix #29392 COM behaved badly for non-existant methods
| -rw-r--r-- | ext/com_dotnet/com_handlers.c | 35 |
1 files changed, 24 insertions, 11 deletions
diff --git a/ext/com_dotnet/com_handlers.c b/ext/com_dotnet/com_handlers.c index cfe15d4355..f0369ce68c 100644 --- a/ext/com_dotnet/com_handlers.c +++ b/ext/com_dotnet/com_handlers.c @@ -307,6 +307,8 @@ static union _zend_function *com_method_get(zval *object, char *name, int len TS f.fn_flags = 0; f.function_name = estrndup(name, len); + fptr = &f; + if (obj->typeinfo) { /* look for byref params */ ITypeComp *comp; @@ -346,6 +348,11 @@ static union _zend_function *com_method_get(zval *object, char *name, int len TS case DESCKIND_TYPECOMP: ITypeComp_Release(bindptr.lptcomp); break; + + case DESCKIND_NONE: + default: + fptr = NULL; + break; } if (TI) { ITypeInfo_Release(TI); @@ -356,21 +363,27 @@ static union _zend_function *com_method_get(zval *object, char *name, int len TS } } - /* save this method in the cache */ - if (!obj->method_cache) { - ALLOC_HASHTABLE(obj->method_cache); - zend_hash_init(obj->method_cache, 2, NULL, function_dtor, 0); - } + if (fptr) { + /* save this method in the cache */ + if (!obj->method_cache) { + ALLOC_HASHTABLE(obj->method_cache); + zend_hash_init(obj->method_cache, 2, NULL, function_dtor, 0); + } - zend_hash_update(obj->method_cache, name, len, &f, sizeof(f), (void**)&fptr); + zend_hash_update(obj->method_cache, name, len, &f, sizeof(f), (void**)&fptr); + } } - /* duplicate this into a new chunk of emalloc'd memory, - * since the engine will efree it */ - func = emalloc(sizeof(*fptr)); - memcpy(func, fptr, sizeof(*fptr)); + if (fptr) { + /* duplicate this into a new chunk of emalloc'd memory, + * since the engine will efree it */ + func = emalloc(sizeof(*fptr)); + memcpy(func, fptr, sizeof(*fptr)); + + return func; + } - return func; + return NULL; } static int com_call_method(char *method, INTERNAL_FUNCTION_PARAMETERS) |
