Fix sign mismatch in valueToString

`valueToString` takes an argument `unsigned int precision`, but it is used with `%d` rather than `%u` in the `snprintf` format string. Make the format string look for an unsigned value instead.
This commit is contained in:
Remy Jette 2017-12-04 17:49:36 -08:00 committed by GitHub
parent e6a588a246
commit 42ca02b833
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -125,7 +125,7 @@ JSONCPP_STRING valueToString(double value, bool useSpecialFloats, unsigned int p
int len = -1; int len = -1;
char formatString[15]; char formatString[15];
snprintf(formatString, sizeof(formatString), "%%.%dg", precision); snprintf(formatString, sizeof(formatString), "%%.%ug", precision);
// Print into the buffer. We need not request the alternative representation // Print into the buffer. We need not request the alternative representation
// that always has a decimal point because JSON doesn't distinguish the // that always has a decimal point because JSON doesn't distinguish the