From 20534bc4459860820cac2a2e97492e7ba3e6d731 Mon Sep 17 00:00:00 2001 From: Wez Furlong Date: Tue, 27 Jul 2004 01:59:44 +0000 Subject: [PATCH] Fix #29392 COM behaved badly for non-existant methods --- ext/com_dotnet/com_handlers.c | 35 ++++++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/ext/com_dotnet/com_handlers.c b/ext/com_dotnet/com_handlers.c index cfe15d43555..f0369ce68c8 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)