From 7f9cc2705c0eb2d424891ab0c470d7c69486fdbb Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Fri, 9 Jun 2017 22:41:48 +0200 Subject: [PATCH] Allocate the proper memory for formatString. Fix a warning with gcc 7.1 /root/firefox-gcc-last/toolkit/components/jsoncpp/src/lib_json/json_writer.cpp:139:16: note: using the range [-2147483648, 2147483647] for directive argument /root/firefox-gcc-last/toolkit/components/jsoncpp/src/lib_json/json_writer.cpp:146:10: note: 'sprintf' output between 5 and 15 bytes into a destination of size 6 sprintf(formatString, "%%.%dg", precision); ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --- src/lib_json/json_writer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib_json/json_writer.cpp b/src/lib_json/json_writer.cpp index 045421532..2ab16acbf 100644 --- a/src/lib_json/json_writer.cpp +++ b/src/lib_json/json_writer.cpp @@ -142,7 +142,7 @@ JSONCPP_STRING valueToString(double value, bool useSpecialFloats, unsigned int p char buffer[36]; int len = -1; - char formatString[6]; + char formatString[15]; snprintf(formatString, sizeof(formatString), "%%.%dg", precision); // Print into the buffer. We need not request the alternative representation