[PATCH] user32: debugstr_format() should not modify the last error.

Francois Gouget fgouget at codeweavers.com
Thu Jun 3 11:44:48 CDT 2021


Signed-off-by: Francois Gouget <fgouget at codeweavers.com>
---
This fixes GetLastError() for EnumClipboardFormats(0xdead) for instance.
---
 dlls/user32/clipboard.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/dlls/user32/clipboard.c b/dlls/user32/clipboard.c
index 2b5e3a85b5d..5176d707b8a 100644
--- a/dlls/user32/clipboard.c
+++ b/dlls/user32/clipboard.c
@@ -81,8 +81,11 @@ struct metafile_pict
 static const char *debugstr_format( UINT id )
 {
     WCHAR buffer[256];
+    DWORD le = GetLastError();
+    BOOL r = GetClipboardFormatNameW( id, buffer, 256 );
+    SetLastError(le);
 
-    if (GetClipboardFormatNameW( id, buffer, 256 ))
+    if (r)
         return wine_dbg_sprintf( "%04x %s", id, debugstr_w(buffer) );
 
     switch (id)
-- 
2.20.1



More information about the wine-devel mailing list