user32/edit: Properly clean up on failure inside WM_NCCREATE handler.
authorNikolay Sivov <bunglehead@gmail.com>
Tue, 20 Oct 2009 17:56:44 +0000 (21:56 +0400)
committerAlexandre Julliard <julliard@winehq.org>
Wed, 21 Oct 2009 14:05:59 +0000 (16:05 +0200)
dlls/user32/edit.c

index 437862bb63fc05f0ac5b438d4eb3d9a1b0ddf4f8..38622cc957f8bf57e1607cf1bed1f50a3a3225be 100644 (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;
 }