From 1a6f78fe2deea81bff8c2d14d6078a51e0c57b60 Mon Sep 17 00:00:00 2001 From: simon Date: Wed, 10 Feb 1999 11:11:11 +0000 Subject: [PATCH] Add DeleteObject calls to go with the CreatePen calls in do_text. Should fix a fairly nasty-looking resource leak. Thanks to Andrew Mobbs. git-svn-id: svn://svn.tartarus.org/sgt/putty@34 cda61777-01e9-0310-a592-d414129be87e --- window.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/window.c b/window.c index 456f1ef5..829abe79 100644 --- a/window.c +++ b/window.c @@ -866,7 +866,10 @@ static int WINAPI WndProc (HWND hwnd, UINT message, if (wParam == SIZE_RESTORED || wParam == SIZE_MAXIMIZED) SetWindowText (hwnd, window_name); if (!ignore_size) { - int width, height, w, h, ew, eh; + int width, height, w, h; +#if 0 /* we have fixed this using WM_SIZING now */ + int ew, eh; +#endif width = LOWORD(lParam); height = HIWORD(lParam); @@ -1084,18 +1087,24 @@ void do_text (Context ctx, int x, int y, char *text, int len, TextOut (hdc, x-1, y, text, len); } if (und_mode == UND_LINE && (attr & ATTR_UNDER)) { - SelectObject (hdc, CreatePen(PS_SOLID, 0, fg)); + HPEN oldpen; + oldpen = SelectObject (hdc, CreatePen(PS_SOLID, 0, fg)); MoveToEx (hdc, x, y+descent, NULL); LineTo (hdc, x+len*font_width, y+descent); + oldpen = SelectObject (hdc, oldpen); + DeleteObject (oldpen); } if (attr & ATTR_PASCURS) { POINT pts[5]; + HPEN oldpen; pts[0].x = pts[1].x = pts[4].x = x; pts[2].x = pts[3].x = x+font_width-1; pts[0].y = pts[3].y = pts[4].y = y; pts[1].y = pts[2].y = y+font_height-1; - SelectObject (hdc, CreatePen(PS_SOLID, 0, colours[23])); + oldpen = SelectObject (hdc, CreatePen(PS_SOLID, 0, colours[23])); Polyline (hdc, pts, 5); + oldpen = SelectObject (hdc, oldpen); + DeleteObject (oldpen); } } -- 2.11.0