Skip to content

Commit 7f9cc27

Browse files
committed
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); ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 parent d7347a2 commit 7f9cc27

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/lib_json/json_writer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ JSONCPP_STRING valueToString(double value, bool useSpecialFloats, unsigned int p
142142
char buffer[36];
143143
int len = -1;
144144

145-
char formatString[6];
145+
char formatString[15];
146146
snprintf(formatString, sizeof(formatString), "%%.%dg", precision);
147147

148148
// Print into the buffer. We need not request the alternative representation

0 commit comments

Comments
 (0)