]> granicus.if.org Git - php/commitdiff
Fix memory leak in the COM extension.
authorWez Furlong <wez@php.net>
Fri, 16 May 2003 19:20:18 +0000 (19:20 +0000)
committerWez Furlong <wez@php.net>
Fri, 16 May 2003 19:20:18 +0000 (19:20 +0000)
Patch from Michael Sisolak <msisolak at yahoo dot com>

ext/com/COM.c

index cdec124de4dd42553b01bbb72295b41500afbe60..10ae498f3595e52354aa5e993ecb3f4f401748db 100644 (file)
@@ -1627,6 +1627,11 @@ static void do_COM_propput(pval *return_value, comval *obj, pval *arg_property,
 
                FREE_VARIANT(var_result);
 
+               /* free the string we allocated; invoked object made its own copy */
+               if (V_VT(new_value) == VT_BSTR) {
+                       VariantClear(new_value);
+               }
+               
                efree(new_value);
                efree(propname);
 
@@ -1659,7 +1664,11 @@ static void do_COM_propput(pval *return_value, comval *obj, pval *arg_property,
                FREE_VARIANT(var_result);
        }
 
-       efree(new_value); // FREE_VARIANT does a VariantClear() which is not desired here !
+       /* free the string we allocated; invoked object made its own copy */
+       if (V_VT(new_value) == VT_BSTR) {
+               VariantClear(new_value);
+       }
+       efree(new_value);
        efree(propname);
 }