mirror of
https://github.com/Tencent/rapidjson.git
synced 2025-03-06 13:41:35 +01:00
Merge pull request #296 from miloyip/issue294_WriteIntSegFault
Try to fix a potential seg fault on some compiler
This commit is contained in:
commit
519a899fa1
@ -109,12 +109,13 @@ inline char* u32toa(uint32_t value, char* buffer) {
|
||||
}
|
||||
|
||||
inline char* i32toa(int32_t value, char* buffer) {
|
||||
uint32_t u = static_cast<uint32_t>(value);
|
||||
if (value < 0) {
|
||||
*buffer++ = '-';
|
||||
value = -value;
|
||||
u = ~u + 1;
|
||||
}
|
||||
|
||||
return u32toa(static_cast<uint32_t>(value), buffer);
|
||||
return u32toa(u, buffer);
|
||||
}
|
||||
|
||||
inline char* u64toa(uint64_t value, char* buffer) {
|
||||
@ -286,12 +287,13 @@ inline char* u64toa(uint64_t value, char* buffer) {
|
||||
}
|
||||
|
||||
inline char* i64toa(int64_t value, char* buffer) {
|
||||
uint64_t u = static_cast<uint64_t>(value);
|
||||
if (value < 0) {
|
||||
*buffer++ = '-';
|
||||
value = -value;
|
||||
u = ~u + 1;
|
||||
}
|
||||
|
||||
return u64toa(static_cast<uint64_t>(value), buffer);
|
||||
return u64toa(u, buffer);
|
||||
}
|
||||
|
||||
} // namespace internal
|
||||
|
Loading…
x
Reference in New Issue
Block a user