user32/edit: Properly clean up on failure inside WM_NCCREATE handler.

This commit is contained in:
Nikolay Sivov 2009-10-20 21:56:44 +04:00 committed by Alexandre Julliard
parent a60966068b
commit e72ed1c421
1 changed files with 11 additions and 3 deletions

View File

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