From 5479adc80fb12db9bf0ca014c21409c6cc92b119 Mon Sep 17 00:00:00 2001 From: Adrian Perez Date: Thu, 27 Jun 2019 09:23:13 -0700 Subject: [PATCH] Fix for FLATBUFFERS_PREFER_PRINTF writing zero-length strings (#5418) --- include/flatbuffers/util.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/flatbuffers/util.h b/include/flatbuffers/util.h index e8c066d5d..f41fca0a5 100644 --- a/include/flatbuffers/util.h +++ b/include/flatbuffers/util.h @@ -102,7 +102,7 @@ std::string NumToStringImplWrapper(T t, const char *fmt, int precision = 0) { size_t string_width = NumToStringWidth(t, precision); std::string s(string_width, 0x00); // Allow snprintf to use std::string trailing null to detect buffer overflow - snprintf(const_cast(s.data()), (s.size() + 1), fmt, precision, t); + snprintf(const_cast(s.data()), (s.size() + 1), fmt, string_width, t); return s; } #endif // FLATBUFFERS_PREFER_PRINTF