From 58e0fb89b218657ce994b4213f5c8956b7a5ecc5 Mon Sep 17 00:00:00 2001 From: Milo Yip Date: Sat, 26 Jul 2014 22:21:06 +0800 Subject: [PATCH] In iterative parsing, always use SizeType to prevent potential alignment problem on some platforms. --- include/rapidjson/reader.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/include/rapidjson/reader.h b/include/rapidjson/reader.h index 5676018..aa8ca01 100644 --- a/include/rapidjson/reader.h +++ b/include/rapidjson/reader.h @@ -1045,9 +1045,9 @@ private: else if (src == IterativeParsingKeyValueDelimiterState) n = IterativeParsingMemberValueState; // Push current state. - *stack_.template Push(1) = n; + *stack_.template Push(1) = n; // Initialize and push the member/element count. - *stack_.template Push(1) = 0; + *stack_.template Push(1) = 0; // Call handler bool hr = (dst == IterativeParsingObjectInitialState) ? handler.StartObject() : handler.StartArray(); // On handler short circuits the parsing. @@ -1096,18 +1096,18 @@ private: case IterativeParsingElementDelimiterState: is.Take(); // Update member/element count. - *stack_.template Top() = *stack_.template Top() + 1; + *stack_.template Top() = *stack_.template Top() + 1; return dst; case IterativeParsingObjectFinishState: { // Get member count. - int c = *stack_.template Pop(1); + SizeType c = *stack_.template Pop(1); // If the object is not empty, count the last member. if (src == IterativeParsingMemberValueState) ++c; // Restore the state. - IterativeParsingState n = *stack_.template Pop(1); + IterativeParsingState n = static_cast(*stack_.template Pop(1)); // Transit to Finish state if this is the topmost scope. if (n == IterativeParsingStartState) n = IterativeParsingFinishState; @@ -1127,12 +1127,12 @@ private: case IterativeParsingArrayFinishState: { // Get element count. - int c = *stack_.template Pop(1); + SizeType c = *stack_.template Pop(1); // If the array is not empty, count the last element. if (src == IterativeParsingElementState) ++c; // Restore the state. - IterativeParsingState n = *stack_.template Pop(1); + IterativeParsingState n = static_cast(*stack_.template Pop(1)); // Transit to Finish state if this is the topmost scope. if (n == IterativeParsingStartState) n = IterativeParsingFinishState;