File tree Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Original file line number Diff line number Diff line change @@ -1034,7 +1034,9 @@ class OurReader {
1034
1034
Location lastValueEnd_;
1035
1035
Value* lastValue_;
1036
1036
std::string commentsBefore_;
1037
- OurFeatures features_;
1037
+ int stackDepth_;
1038
+
1039
+ OurFeatures const features_;
1038
1040
bool collectComments_;
1039
1041
}; // OurReader
1040
1042
@@ -1065,6 +1067,7 @@ bool OurReader::parse(const char* beginDoc,
1065
1067
nodes_.pop ();
1066
1068
nodes_.push (&root);
1067
1069
1070
+ stackDepth_ = 0 ;
1068
1071
bool successful = readValue ();
1069
1072
Token token;
1070
1073
skipCommentTokens (token);
@@ -1087,6 +1090,8 @@ bool OurReader::parse(const char* beginDoc,
1087
1090
}
1088
1091
1089
1092
bool OurReader::readValue () {
1093
+ if (stackDepth_ >= features_.stackLimit_ ) throw std::runtime_error (" Exceeded stackLimit in readValue()." );
1094
+ ++stackDepth_;
1090
1095
Token token;
1091
1096
skipCommentTokens (token);
1092
1097
bool successful = true ;
@@ -1158,6 +1163,7 @@ bool OurReader::readValue() {
1158
1163
lastValue_ = ¤tValue ();
1159
1164
}
1160
1165
1166
+ --stackDepth_;
1161
1167
return successful;
1162
1168
}
1163
1169
You can’t perform that action at this time.
0 commit comments