]> granicus.if.org Git - php/commitdiff
Fix #29392 COM behaved badly for non-existant methods
authorWez Furlong <wez@php.net>
Tue, 27 Jul 2004 01:59:44 +0000 (01:59 +0000)
committerWez Furlong <wez@php.net>
Tue, 27 Jul 2004 01:59:44 +0000 (01:59 +0000)
ext/com_dotnet/com_handlers.c

index cfe15d43555f6e73e0f0bbb5e1dc3c29edeacfd0..f0369ce68c84c4d0054031372b0da0297fbe081b 100644 (file)
@@ -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)