From bf4cdfad5be250e4fc34441da3133e96a92c04fb Mon Sep 17 00:00:00 2001 From: Jacek Caban Date: Thu, 9 Sep 2021 14:01:47 +0200 Subject: [PATCH] gdi32: Support NULL prev_value in NtGdiGetAndSetDCDword. Signed-off-by: Jacek Caban Signed-off-by: Huw Davies Signed-off-by: Alexandre Julliard --- dlls/gdi32/dc.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/dlls/gdi32/dc.c b/dlls/gdi32/dc.c index 4ed09e91eb1..ae6119529f5 100644 --- a/dlls/gdi32/dc.c +++ b/dlls/gdi32/dc.c @@ -830,6 +830,7 @@ BOOL WINAPI NtGdiGetAndSetDCDword( HDC hdc, UINT method, DWORD value, DWORD *pre { PHYSDEV physdev; BOOL ret = TRUE; + DWORD prev; DC *dc; if (!(dc = get_dc_ptr( hdc ))) return 0; @@ -837,36 +838,36 @@ BOOL WINAPI NtGdiGetAndSetDCDword( HDC hdc, UINT method, DWORD value, DWORD *pre switch (method) { case NtGdiSetMapMode: - *prev_value = dc->attr->map_mode; + prev = dc->attr->map_mode; ret = set_map_mode( dc, value ); break; case NtGdiSetBkColor: - *prev_value = dc->attr->background_color; + prev = dc->attr->background_color; set_bk_color( dc, value ); break; case NtGdiSetTextColor: - *prev_value = dc->attr->text_color; + prev = dc->attr->text_color; set_text_color( dc, value ); break; case NtGdiSetDCBrushColor: physdev = GET_DC_PHYSDEV( dc, pSetDCBrushColor ); - *prev_value = dc->attr->brush_color; + prev = dc->attr->brush_color; value = physdev->funcs->pSetDCBrushColor( physdev, value ); if (value != CLR_INVALID) dc->attr->brush_color = value; break; case NtGdiSetDCPenColor: physdev = GET_DC_PHYSDEV( dc, pSetDCPenColor ); - *prev_value = dc->attr->pen_color; + prev = dc->attr->pen_color; value = physdev->funcs->pSetDCPenColor( physdev, value ); if (value != CLR_INVALID) dc->attr->pen_color = value; break; case NtGdiSetGraphicsMode: - if (prev_value) *prev_value = dc->attr->graphics_mode; + prev = dc->attr->graphics_mode; ret = set_graphics_mode( dc, value ); break; @@ -877,7 +878,9 @@ BOOL WINAPI NtGdiGetAndSetDCDword( HDC hdc, UINT method, DWORD value, DWORD *pre } release_dc_ptr( dc ); - return ret; + if (!ret || !prev_value) return FALSE; + *prev_value = prev; + return TRUE; }