From 54c83ce7a388218bd24ae0ca51fce55fad8d10b5 Mon Sep 17 00:00:00 2001 From: Wez Furlong Date: Fri, 16 May 2003 19:20:18 +0000 Subject: [PATCH] Fix memory leak in the COM extension. Patch from Michael Sisolak --- ext/com/COM.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/ext/com/COM.c b/ext/com/COM.c index cdec124de4..10ae498f35 100644 --- a/ext/com/COM.c +++ b/ext/com/COM.c @@ -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); } -- 2.50.1