From 42ca02b83399c42efee63344574260cbdb38d075 Mon Sep 17 00:00:00 2001 From: Remy Jette Date: Mon, 4 Dec 2017 17:49:36 -0800 Subject: [PATCH] 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. --- 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 9a912acf8..de26b242b 100644 --- a/src/lib_json/json_writer.cpp +++ b/src/lib_json/json_writer.cpp @@ -125,7 +125,7 @@ JSONCPP_STRING valueToString(double value, bool useSpecialFloats, unsigned int p int len = -1; 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 // that always has a decimal point because JSON doesn't distinguish the