Skip to content

Commit

Permalink
Allocate the proper memory for formatString. Fix a warning with gcc 7.1
Browse files Browse the repository at this point in the history
/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);
   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  • Loading branch information
sylvestre committed Jun 9, 2017
1 parent d7347a2 commit 7f9cc27
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/lib_json/json_writer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 7f9cc27

Please sign in to comment.