]> granicus.if.org Git - php/commitdiff
Fixed bug #34272 (empty array onto COM object blows up)
authorRob Richards <rrichards@php.net>
Sat, 4 Feb 2006 10:57:28 +0000 (10:57 +0000)
committerRob Richards <rrichards@php.net>
Sat, 4 Feb 2006 10:57:28 +0000 (10:57 +0000)
fix mem leaks
WS fixes
add test

ext/com_dotnet/com_handlers.c
ext/com_dotnet/com_variant.c
ext/com_dotnet/tests/bug34272.phpt [new file with mode: 0644]

index 0fb3787c882ff04bea1033dcd436c3a99c1450bb..04c771c9d6953a04886281a90ebc681b167af897 100644 (file)
@@ -634,9 +634,11 @@ void php_com_object_free_storage(void *object TSRMLS_DC)
        VariantClear(&obj->v);
 
        if (obj->method_cache) {
+               zend_hash_destroy(obj->method_cache);
                FREE_HASHTABLE(obj->method_cache);
        }
        if (obj->id_of_name_cache) {
+               zend_hash_destroy(obj->id_of_name_cache);
                FREE_HASHTABLE(obj->id_of_name_cache);
        }
        efree(obj);
index 56e643efbdba47c48e47358faebec80d83adfeb0..ae350fe1d87602f0d3ecd074ca5271d2056fce78 100644 (file)
@@ -40,7 +40,7 @@ static void safe_array_from_zval(VARIANT *v, zval *z, int codepage TSRMLS_DC)
        int keytype;
        char *strindex;
        int strindexlen;
-       long intindex;
+       long intindex = -1;
        long max_index = 0;
        VARIANT *va;
        zval **item;
diff --git a/ext/com_dotnet/tests/bug34272.phpt b/ext/com_dotnet/tests/bug34272.phpt
new file mode 100644 (file)
index 0000000..3a65e2c
--- /dev/null
@@ -0,0 +1,22 @@
+--TEST--
+Bug #34272 (empty array onto COM object blows up)
+--SKIPIF--
+<?php 
+if (!extension_loaded("com_dotnet")) print "skip COM/.Net support not present"; ?>
+--FILE--
+<?php 
+error_reporting(E_ALL);
+
+try {
+       $dict = new COM("Scripting.Dictionary");
+       $dict->add('foo', array());
+       print sizeof($dict['foo'])."\n";
+       $dict->add('bar', array(23));
+       print sizeof($dict['bar'])." \n";
+} catch (Exception $e) {
+       print $e;
+}
+?>
+--EXPECT--
+0
+1