From 60d8c481320c2ee05eaa95db15d61bfdb6306715 Mon Sep 17 00:00:00 2001 From: Jacek Caban Date: Thu, 20 Jan 2011 11:48:56 +0100 Subject: [PATCH] mshtml: Fixed leaks (valgrind). --- dlls/mshtml/htmlform.c | 39 +++------------------------------------ dlls/mshtml/nsio.c | 1 + 2 files changed, 4 insertions(+), 36 deletions(-) diff --git a/dlls/mshtml/htmlform.c b/dlls/mshtml/htmlform.c index b51cf61fce6..3dff3766f84 100644 --- a/dlls/mshtml/htmlform.c +++ b/dlls/mshtml/htmlform.c @@ -228,17 +228,7 @@ static HRESULT WINAPI HTMLFormElement_get_encoding(IHTMLFormElement *iface, BSTR nsAString_Init(&encoding_str, NULL); nsres = nsIDOMHTMLFormElement_GetEnctype(This->nsform, &encoding_str); - if(NS_SUCCEEDED(nsres)) { - const PRUnichar *encoding; - nsAString_GetData(&encoding_str, &encoding); - - *p = SysAllocString(encoding); - if(!*p) - return E_OUTOFMEMORY; - }else - return E_FAIL; - - return S_OK; + return return_nsstr(nsres, &encoding_str, p); } static HRESULT WINAPI HTMLFormElement_put_method(IHTMLFormElement *iface, BSTR v) @@ -276,17 +266,7 @@ static HRESULT WINAPI HTMLFormElement_get_method(IHTMLFormElement *iface, BSTR * nsAString_Init(&method_str, NULL); nsres = nsIDOMHTMLFormElement_GetMethod(This->nsform, &method_str); - if(NS_SUCCEEDED(nsres)) { - const PRUnichar *method; - nsAString_GetData(&method_str, &method); - - *p = SysAllocString(method); - if(!*p) - return E_OUTOFMEMORY; - }else - return E_FAIL; - - return S_OK; + return return_nsstr(nsres, &method_str, p); } static HRESULT WINAPI HTMLFormElement_get_elements(IHTMLFormElement *iface, IDispatch **p) @@ -337,20 +317,7 @@ static HRESULT WINAPI HTMLFormElement_get_name(IHTMLFormElement *iface, BSTR *p) nsAString_Init(&name_str, NULL); nsres = nsIDOMHTMLFormElement_GetName(This->nsform, &name_str); - if(NS_SUCCEEDED(nsres)) { - const PRUnichar *name; - nsAString_GetData(&name_str, &name); - - if(*name) { - *p = SysAllocString(name); - if(!*p) - return E_OUTOFMEMORY; - }else - *p = NULL; - }else - return E_FAIL; - - return S_OK; + return return_nsstr(nsres, &name_str, p); } static HRESULT WINAPI HTMLFormElement_put_onsubmit(IHTMLFormElement *iface, VARIANT v) diff --git a/dlls/mshtml/nsio.c b/dlls/mshtml/nsio.c index 617b3f3be99..b6887fafd71 100644 --- a/dlls/mshtml/nsio.c +++ b/dlls/mshtml/nsio.c @@ -2007,6 +2007,7 @@ static nsresult NSAPI nsURI_SchemeIs(nsIURL *iface, const char *scheme, PRBool * MultiByteToWideChar(CP_ACP, 0, scheme, -1, buf, sizeof(buf)/sizeof(WCHAR)); *_retval = !strcmpW(scheme_name, buf); + SysFreeString(scheme_name); return NS_OK; }