win32/HResult: convert assert() to runtime check to work around -Walloc-size-larger-than
This commit is contained in:
parent
a654c5d643
commit
6e6f72a521
|
@ -100,9 +100,11 @@ FormatHResultError(HRESULT result, const char *fmt, ...) noexcept
|
||||||
va_start(args1, fmt);
|
va_start(args1, fmt);
|
||||||
va_copy(args2, args1);
|
va_copy(args2, args1);
|
||||||
|
|
||||||
const int size = vsnprintf(nullptr, 0, fmt, args1);
|
int size = vsnprintf(nullptr, 0, fmt, args1);
|
||||||
va_end(args1);
|
va_end(args1);
|
||||||
assert(size >= 0);
|
|
||||||
|
if (size < 0)
|
||||||
|
size = 0;
|
||||||
|
|
||||||
auto buffer = std::make_unique<char[]>(size + 1);
|
auto buffer = std::make_unique<char[]>(size + 1);
|
||||||
vsprintf(buffer.get(), fmt, args2);
|
vsprintf(buffer.get(), fmt, args2);
|
||||||
|
|
Loading…
Reference in New Issue