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

Fixes a memory leak on an error path. Found by Smatch.
This commit is contained in:
Michael Stefaniuc 2009-05-16 21:43:06 +02:00 committed by Alexandre Julliard
parent d39dd38346
commit 850f6c7965
1 changed files with 8 additions and 8 deletions

View File

@ -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);