From a1b6164ef15cf4be3b1914f2df7125fc7ffc7ca8 Mon Sep 17 00:00:00 2001 From: Andrei Polushin Date: Fri, 12 Aug 2022 20:18:55 +0700 Subject: [PATCH] windows: call to FormatMessage() should _IGNORE_INSERTS (#849) Calling FormatMessage without a FORMAT_MESSAGE_IGNORE_INSERTS flag could cause trouble, as explained in an article by Raymond Chen: * The importance of the FORMAT_MESSAGE_IGNORE_INSERTS flag https://devblogs.microsoft.com/oldnewthing/20071128-00/?p=24353 --- src/glog/logging.h.in | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/glog/logging.h.in b/src/glog/logging.h.in index ef404f6..8a26cbc 100644 --- a/src/glog/logging.h.in +++ b/src/glog/logging.h.in @@ -596,7 +596,8 @@ DECLARE_bool(log_utc_time); LPSTR message = NULL; \ LPSTR msg = reinterpret_cast(&message); \ DWORD message_length = FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER | \ - FORMAT_MESSAGE_FROM_SYSTEM, \ + FORMAT_MESSAGE_FROM_SYSTEM | \ + FORMAT_MESSAGE_IGNORE_INSERTS, \ 0, result, 0, msg, 100, NULL); \ if (message_length > 0) { \ @ac_google_namespace@::LogMessage(__FILE__, __LINE__, @ac_google_namespace@::GLOG_ERROR, 0, \