From 6e6f72a5210085a8c00b1858114744e810215edf Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Wed, 20 Dec 2023 15:12:19 +0100 Subject: [PATCH] win32/HResult: convert assert() to runtime check to work around -Walloc-size-larger-than --- src/win32/HResult.cxx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/win32/HResult.cxx b/src/win32/HResult.cxx index a4e04caa6..c5e522464 100644 --- a/src/win32/HResult.cxx +++ b/src/win32/HResult.cxx @@ -100,9 +100,11 @@ FormatHResultError(HRESULT result, const char *fmt, ...) noexcept va_start(args1, fmt); va_copy(args2, args1); - const int size = vsnprintf(nullptr, 0, fmt, args1); + int size = vsnprintf(nullptr, 0, fmt, args1); va_end(args1); - assert(size >= 0); + + if (size < 0) + size = 0; auto buffer = std::make_unique(size + 1); vsprintf(buffer.get(), fmt, args2);