Fix the undefined behaviour when negating the minimum value integers in Reader

This commit is contained in:
miloyip 2015-05-21 16:00:32 +08:00
parent f688b2b152
commit 1a570c342d

View File

@ -967,13 +967,13 @@ private:
else { else {
if (use64bit) { if (use64bit) {
if (minus) if (minus)
cont = handler.Int64(-(int64_t)i64); cont = handler.Int64(static_cast<int64_t>(~i64 + 1));
else else
cont = handler.Uint64(i64); cont = handler.Uint64(i64);
} }
else { else {
if (minus) if (minus)
cont = handler.Int(-(int)i); cont = handler.Int(static_cast<int32_t>(~i + 1));
else else
cont = handler.Uint(i); cont = handler.Uint(i);
} }