Commit 850f6c79 authored by Michael Stefaniuc's avatar Michael Stefaniuc Committed by Alexandre Julliard

msctf: Allocate memory only right before it's needed.

Fixes a memory leak on an error path. Found by Smatch.
parent d39dd383
......@@ -358,14 +358,6 @@ HRESULT add_active_textservice(TF_LANGUAGEPROFILE *lp)
actsvr = HeapAlloc(GetProcessHeap(),0,sizeof(ActivatedTextService));
if (!actsvr) return E_OUTOFMEMORY;
entry = HeapAlloc(GetProcessHeap(),0,sizeof(AtsEntry));
if (!entry)
{
HeapFree(GetProcessHeap(),0,actsvr);
return E_OUTOFMEMORY;
}
ITfThreadMgr_QueryInterface(tm,&IID_ITfClientId,(LPVOID)&clientid);
ITfClientId_GetClientId(clientid, &lp->clsid, &actsvr->tid);
ITfClientId_Release(clientid);
......@@ -404,6 +396,14 @@ HRESULT add_active_textservice(TF_LANGUAGEPROFILE *lp)
if (activated > 0)
activate_given_ts(actsvr, tm);
entry = HeapAlloc(GetProcessHeap(),0,sizeof(AtsEntry));
if (!entry)
{
HeapFree(GetProcessHeap(),0,actsvr);
return E_OUTOFMEMORY;
}
entry->ats = actsvr;
list_add_head(&AtsList, &entry->entry);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment