Skip to content

Commit

Permalink
fix Windows handle resource leak when displaying many emojis (mintty/…
Browse files Browse the repository at this point in the history
  • Loading branch information
mintty committed Aug 20, 2019
1 parent ba9cb74 commit 3af84e5
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/winimg.c
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,7 @@ winimg_paint(void)
img = img->next;
}
}

ReleaseDC(wnd, dc);
}

Expand Down Expand Up @@ -519,8 +520,10 @@ win_emoji_show(int x, int y, wchar * efn, int elen, ushort lattr)
}
}

HDC dc = GetDC(wnd);
GpGraphics * gr;
s = GdipCreateFromHDC(GetDC(wnd), &gr);
s = GdipCreateFromHDC(dc, &gr);

gpcheck("hdc", s);
s = GdipDrawImageRectI(gr, img, col, row, w, h);
gpcheck("draw", s);
Expand All @@ -531,6 +534,9 @@ win_emoji_show(int x, int y, wchar * efn, int elen, ushort lattr)
gpcheck("delete gr", s);
s = GdipDisposeImage(img);
gpcheck("dispose img", s);

ReleaseDC(wnd, dc);

if (fs) {
// Release stream resources, close file.
fs->lpVtbl->Release(fs);
Expand Down

0 comments on commit 3af84e5

Please sign in to comment.