Michael Stefaniuc : msctf: Allocate memory only right before it's needed.
Alexandre Julliard
julliard at winehq.org
Mon May 18 08:13:13 CDT 2009
Module: wine
Branch: master
Commit: 850f6c796569e90907845eaabba19e07136baecd
URL: http://source.winehq.org/git/wine.git/?a=commit;h=850f6c796569e90907845eaabba19e07136baecd
Author: Michael Stefaniuc <mstefani at redhat.de>
Date: Sat May 16 21:43:06 2009 +0200
msctf: Allocate memory only right before it's needed.
Fixes a memory leak on an error path. Found by Smatch.
---
dlls/msctf/msctf.c | 16 ++++++++--------
1 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/dlls/msctf/msctf.c b/dlls/msctf/msctf.c
index 55a8075..675e4d5 100644
--- a/dlls/msctf/msctf.c
+++ b/dlls/msctf/msctf.c
@@ -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);
More information about the wine-cvs
mailing list