[PATCH 5/8] Properly clean up on failure inside WM_NCCREATE handler

Nikolay Sivov bunglehead at gmail.com
Tue Oct 20 12:56:44 CDT 2009


---
 dlls/user32/edit.c |   14 +++++++++++---
 1 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/dlls/user32/edit.c b/dlls/user32/edit.c
index 437862b..38622cc 100644
--- a/dlls/user32/edit.c
+++ b/dlls/user32/edit.c
@@ -4599,16 +4599,16 @@ static LRESULT EDIT_WM_NCCreate(HWND hwnd, LPCREATESTRUCTW lpcs, BOOL unicode)
 
 	alloc_size = ROUND_TO_GROW((es->buffer_size + 1) * sizeof(WCHAR));
 	if(!(es->hloc32W = LocalAlloc(LMEM_MOVEABLE | LMEM_ZEROINIT, alloc_size)))
-	    return FALSE;
+	    goto cleanup;
 	es->buffer_size = LocalSize(es->hloc32W)/sizeof(WCHAR) - 1;
 
 	if (!(es->undo_text = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, (es->buffer_size + 1) * sizeof(WCHAR))))
-		return FALSE;
+		goto cleanup;
 	es->undo_buffer_size = es->buffer_size;
 
 	if (es->style & ES_MULTILINE)
 		if (!(es->first_line_def = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(LINEDEF))))
-			return FALSE;
+			goto cleanup;
 	es->line_count = 1;
 
 	/*
@@ -4628,6 +4628,14 @@ static LRESULT EDIT_WM_NCCreate(HWND hwnd, LPCREATESTRUCTW lpcs, BOOL unicode)
 		SetWindowLongW(hwnd, GWL_STYLE, es->style & ~WS_BORDER);
 
 	return TRUE;
+
+cleanup:
+	SetWindowLongPtrW(es->hwndSelf, 0, 0);
+	HeapFree(GetProcessHeap(), 0, es->first_line_def);
+	HeapFree(GetProcessHeap(), 0, es->undo_text);
+	if (es->hloc32W) LocalFree(es->hloc32W);
+	HeapFree(GetProcessHeap(), 0, es);
+	return FALSE;
 }
 
 
-- 
1.5.6.5


--=-TZIpSqeuNT8cE3OUw7w1--




More information about the wine-patches mailing list