Module: wine Branch: master Commit: c09f1357bccbdf25ab7b46d508c27fad5801bac4 URL: http://source.winehq.org/git/wine.git/?a=commit;h=c09f1357bccbdf25ab7b46d508...
Author: Paul TBBle Hampson Paul.Hampson@Pobox.com Date: Tue Feb 3 09:39:32 2009 +1100
winefile: Don't use child after it has been freed.
If winefile is unable to create a window, it frees the child pointer. However, it then proceeds to use the child pointer.
---
programs/winefile/winefile.c | 17 ++++++++++++----- 1 files changed, 12 insertions(+), 5 deletions(-)
diff --git a/programs/winefile/winefile.c b/programs/winefile/winefile.c index aefe7bd..0193c7b 100644 --- a/programs/winefile/winefile.c +++ b/programs/winefile/winefile.c @@ -4706,7 +4706,7 @@ static void InitInstance(HINSTANCE hinstance) }
-static void show_frame(HWND hwndParent, int cmdshow, LPCTSTR path) +static BOOL show_frame(HWND hwndParent, int cmdshow, LPCTSTR path) { static const TCHAR sMDICLIENT[] = {'M','D','I','C','L','I','E','N','T','\0'};
@@ -4718,7 +4718,7 @@ static void show_frame(HWND hwndParent, int cmdshow, LPCTSTR path) CLIENTCREATESTRUCT ccs;
if (Globals.hMainWnd) - return; + return TRUE;
opts = load_registry_settings(); hMenuFrame = LoadMenu(Globals.hInstance, MAKEINTRESOURCE(IDM_WINEFILE)); @@ -4796,8 +4796,10 @@ static void show_frame(HWND hwndParent, int cmdshow, LPCTSTR path) child->pos.rcNormalPosition.right = 320; child->pos.rcNormalPosition.bottom = 280;
- if (!create_child_window(child)) + if (!create_child_window(child)) { HeapFree(GetProcessHeap(), 0, child); + return FALSE; + }
SetWindowPlacement(child->hwnd, &child->pos);
@@ -4807,7 +4809,7 @@ static void show_frame(HWND hwndParent, int cmdshow, LPCTSTR path)
UpdateWindow(Globals.hMainWnd);
- if (path && path[0]) + if (child->hwnd && path && path[0]) { int index,count; TCHAR drv[_MAX_DRIVE+1], dir[_MAX_DIR], name[_MAX_FNAME], ext[_MAX_EXT]; @@ -4835,6 +4837,7 @@ static void show_frame(HWND hwndParent, int cmdshow, LPCTSTR path) } } } + return TRUE; }
static void ExitInstance(void) @@ -4888,7 +4891,11 @@ static int winefile_main(HINSTANCE hinstance, int cmdshow, LPCTSTR path)
InitInstance(hinstance);
- show_frame(0, cmdshow, path); + if( !show_frame(0, cmdshow, path) ) + { + ExitInstance(); + return 1; + }
while(GetMessage(&msg, 0, 0, 0)) { if (Globals.hmdiclient && TranslateMDISysAccel(Globals.hmdiclient, &msg))