Module: wine Branch: master Commit: 8b55affe3e6f9e85893bc11a55e980e8aa6d976d URL: https://gitlab.winehq.org/wine/wine/-/commit/8b55affe3e6f9e85893bc11a55e980e...
Author: Esme Povirk esme@codeweavers.com Date: Sat May 4 20:32:57 2024 +0000
gdiplus: Bracket HDC use in GDI32_GdipDrawDriverString.
---
dlls/gdiplus/graphics.c | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-)
diff --git a/dlls/gdiplus/graphics.c b/dlls/gdiplus/graphics.c index c089a984db7..83fca7a9bfa 100644 --- a/dlls/gdiplus/graphics.c +++ b/dlls/gdiplus/graphics.c @@ -7492,6 +7492,7 @@ static GpStatus GDI32_GdipDrawDriverString(GpGraphics *graphics, GDIPCONST UINT1 LOGFONTW lfw; UINT eto_flags=0; GpStatus status; + HDC hdc; HRGN hrgn;
if (!(flags & DriverStringOptionsCmapLookup)) @@ -7509,15 +7510,23 @@ static GpStatus GDI32_GdipDrawDriverString(GpGraphics *graphics, GDIPCONST UINT1 } }
- save_state = SaveDC(graphics->hdc); - SetBkMode(graphics->hdc, TRANSPARENT); - SetTextColor(graphics->hdc, get_gdi_brush_color(brush)); + status = gdi_dc_acquire(graphics, &hdc); + if (status != Ok) + { + free(real_positions); + free(eto_positions); + return status; + } + + save_state = SaveDC(hdc); + SetBkMode(hdc, TRANSPARENT); + SetTextColor(hdc, get_gdi_brush_color(brush));
status = get_clip_hrgn(graphics, &hrgn);
if (status == Ok) { - ExtSelectClipRgn(graphics->hdc, hrgn, RGN_COPY); + ExtSelectClipRgn(hdc, hrgn, RGN_COPY); DeleteObject(hrgn); }
@@ -7548,23 +7557,25 @@ static GpStatus GDI32_GdipDrawDriverString(GpGraphics *graphics, GDIPCONST UINT1 } }
- SelectObject(graphics->hdc, hfont); + SelectObject(hdc, hfont);
- SetTextAlign(graphics->hdc, TA_BASELINE|TA_LEFT); + SetTextAlign(hdc, TA_BASELINE|TA_LEFT);
gdi_transform_acquire(graphics);
- ExtTextOutW(graphics->hdc, gdip_round(pt.X), gdip_round(pt.Y), eto_flags, NULL, text, length, eto_positions); + ExtTextOutW(hdc, gdip_round(pt.X), gdip_round(pt.Y), eto_flags, NULL, text, length, eto_positions);
gdi_transform_release(graphics);
- RestoreDC(graphics->hdc, save_state); + RestoreDC(hdc, save_state);
DeleteObject(hfont);
free(real_positions); free(eto_positions);
+ gdi_dc_release(graphics, hdc); + return Ok; }