From 1a570c342dad0927503b35782263da006ef93351 Mon Sep 17 00:00:00 2001 From: miloyip Date: Thu, 21 May 2015 16:00:32 +0800 Subject: [PATCH] Fix the undefined behaviour when negating the minimum value integers in Reader --- include/rapidjson/reader.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/rapidjson/reader.h b/include/rapidjson/reader.h index be0d9fb..8989e38 100644 --- a/include/rapidjson/reader.h +++ b/include/rapidjson/reader.h @@ -967,13 +967,13 @@ private: else { if (use64bit) { if (minus) - cont = handler.Int64(-(int64_t)i64); + cont = handler.Int64(static_cast(~i64 + 1)); else cont = handler.Uint64(i64); } else { if (minus) - cont = handler.Int(-(int)i); + cont = handler.Int(static_cast(~i + 1)); else cont = handler.Uint(i); }