From 1032c9b91771d2cbd8c1cea9aef6eff4454fb100 Mon Sep 17 00:00:00 2001 From: Peter Johnson Date: Tue, 16 Mar 2021 22:04:55 -0700 Subject: [PATCH] [wpiutil] Unbreak wpi::Format on Windows (#3242) This function relies on the behavior of snprintf returning an error value when the buffer is too small. By default, _snprintf_s aborts on Windows instead of returning an error value. This caused Glass to fail when trying to print a large NT value to a string. --- wpiutil/src/main/native/include/wpi/Format.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wpiutil/src/main/native/include/wpi/Format.h b/wpiutil/src/main/native/include/wpi/Format.h index cb8b26b809..ac4886a110 100644 --- a/wpiutil/src/main/native/include/wpi/Format.h +++ b/wpiutil/src/main/native/include/wpi/Format.h @@ -95,7 +95,7 @@ class format_object final : public format_object_base { int snprint_tuple(char *Buffer, unsigned BufferSize, std::index_sequence) const { #ifdef _MSC_VER - return _snprintf_s(Buffer, BufferSize, BufferSize, Fmt, std::get(Vals)...); + return _snprintf(Buffer, BufferSize, Fmt, std::get(Vals)...); #else #ifdef __GNUC__ #pragma GCC diagnostic push