Skip to content

Commit 6bf92cf

Browse files
committed
Fixed json number serialization on 32 and 64 bit linux
1 parent 78e6c0c commit 6bf92cf

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

Release/src/json/json_serialization.cpp

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -145,9 +145,16 @@ void web::json::details::_Number::format(std::basic_string<char>& stream) const
145145

146146
const auto numChars = strnlen_s(tempBuffer, tempSize);
147147
#else
148-
const auto numChars = m_number.m_type == number::type::signed_type ?
149-
std::snprintf(tempBuffer, tempSize, "%lli", m_number.m_intval) :
150-
std::snprintf(tempBuffer, tempSize, "%llu", m_number.m_uintval);
148+
std::stringstream ss;
149+
if (m_number.m_type == number::type::signed_type)
150+
ss << m_number.m_intval;
151+
else
152+
ss << m_number.m_uintval;
153+
154+
std::string s = ss.str();
155+
strncpy(tempBuffer, s.c_str(), tempSize - 1);
156+
tempBuffer[tempSize - 1] = '\0';
157+
const auto numChars = strlen(tempBuffer);
151158
#endif
152159
stream.append(tempBuffer, numChars);
153160
}

0 commit comments

Comments
 (0)