From e10adb1c2b81c8b3f1e280b7d32ff63bbfe56c71 Mon Sep 17 00:00:00 2001 From: Luca Bacci Date: Thu, 16 Jan 2025 14:33:58 +0100 Subject: [PATCH] Win32: Pass FORMAT_MESSAGE_IGNORE_INSERTS This should always be passed when retreving messages from third parties (unless the third party documents format strings) See https://devblogs.microsoft.com/oldnewthing/20071128-00/?p=24353 --- boilerplate/cairo-boilerplate-win32-printing.c | 1 + src/win32/cairo-dwrite-font.cpp | 1 + src/win32/cairo-win32-surface.c | 1 + 3 files changed, 3 insertions(+) diff --git a/boilerplate/cairo-boilerplate-win32-printing.c b/boilerplate/cairo-boilerplate-win32-printing.c index a3802d2e9..a156deb24 100644 --- a/boilerplate/cairo-boilerplate-win32-printing.c +++ b/boilerplate/cairo-boilerplate-win32-printing.c @@ -43,6 +43,7 @@ _cairo_win32_print_gdi_error (const char *context) DWORD last_error = GetLastError (); if (!FormatMessageW (FORMAT_MESSAGE_ALLOCATE_BUFFER | + FORMAT_MESSAGE_IGNORE_INSERTS | FORMAT_MESSAGE_FROM_SYSTEM, NULL, last_error, diff --git a/src/win32/cairo-dwrite-font.cpp b/src/win32/cairo-dwrite-font.cpp index f7d1c4767..74d12c6a0 100644 --- a/src/win32/cairo-dwrite-font.cpp +++ b/src/win32/cairo-dwrite-font.cpp @@ -110,6 +110,7 @@ _cairo_dwrite_error (HRESULT hr, const char *context) void *lpMsgBuf; if (!FormatMessageW (FORMAT_MESSAGE_ALLOCATE_BUFFER | + FORMAT_MESSAGE_IGNORE_INSERTS | FORMAT_MESSAGE_FROM_SYSTEM, NULL, hr, diff --git a/src/win32/cairo-win32-surface.c b/src/win32/cairo-win32-surface.c index 6e82638ff..6862e2090 100644 --- a/src/win32/cairo-win32-surface.c +++ b/src/win32/cairo-win32-surface.c @@ -95,6 +95,7 @@ _cairo_win32_print_gdi_error (const char *context) DWORD last_error = GetLastError (); if (!FormatMessageW (FORMAT_MESSAGE_ALLOCATE_BUFFER | + FORMAT_MESSAGE_IGNORE_INSERTS | FORMAT_MESSAGE_FROM_SYSTEM, NULL, last_error,