summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ext/com_dotnet/com_handlers.c35
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)