patch applied from Christoph at ApiViewer.de: fix font handle leak
authorMartin Fuchs <fuchs.martin@gmail.com>
Fri, 30 Sep 2005 19:42:45 +0000 (19:42 +0000)
committerMartin Fuchs <fuchs.martin@gmail.com>
Fri, 30 Sep 2005 19:42:45 +0000 (19:42 +0000)
svn path=/trunk/; revision=18174

reactos/subsys/system/winefile/winefile.c

index 48f3fe2..f5cb83b 100644 (file)
@@ -2247,9 +2247,11 @@ static LRESULT CALLBACK FrameWndProc(HWND hwnd, UINT nmsg, WPARAM wparam, LPARAM
 
                                        if (ChooseFont(&chFont)) {
                                                HWND childWnd;
+                                               HFONT hFontOld;
 
+                                               DeleteObject(Globals.hfont);
                                                Globals.hfont = CreateFontIndirect(&lFont);
-                                               SelectFont(hdc, Globals.hfont);
+                                               hFontOld = SelectFont(hdc, Globals.hfont);
                                                GetTextExtentPoint32(hdc, sSpace, 1, &Globals.spaceSize);
 
                                                /* change font in all open child windows */
@@ -2262,6 +2264,8 @@ static LRESULT CALLBACK FrameWndProc(HWND hwnd, UINT nmsg, WPARAM wparam, LPARAM
                                                        InvalidateRect(child->left.hwnd, NULL, TRUE);
                                                        InvalidateRect(child->right.hwnd, NULL, TRUE);
                                                }
+
+                                               SelectFont(hdc, hFontOld);
                                        }
                                        else if (CommDlgExtendedError()) {
                                                LoadString(Globals.hInstance, IDS_FONT_SEL_DLG_NAME, dlg_name, BUFFER_LEN);
@@ -4774,6 +4778,7 @@ static void ExitInstance(void)
        CoUninitialize();
 #endif
 
+       DeleteObject(Globals.hfont);
        ImageList_Destroy(Globals.himl);
 }