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 {
10341034 Location lastValueEnd_;
10351035 Value* lastValue_;
10361036 std::string commentsBefore_;
1037- OurFeatures features_;
1037+ int stackDepth_;
1038+
1039+ OurFeatures const features_;
10381040 bool collectComments_;
10391041}; // OurReader
10401042
@@ -1065,6 +1067,7 @@ bool OurReader::parse(const char* beginDoc,
10651067 nodes_.pop ();
10661068 nodes_.push (&root);
10671069
1070+ stackDepth_ = 0 ;
10681071 bool successful = readValue ();
10691072 Token token;
10701073 skipCommentTokens (token);
@@ -1087,6 +1090,8 @@ bool OurReader::parse(const char* beginDoc,
10871090}
10881091
10891092bool OurReader::readValue () {
1093+ if (stackDepth_ >= features_.stackLimit_ ) throw std::runtime_error (" Exceeded stackLimit in readValue()." );
1094+ ++stackDepth_;
10901095 Token token;
10911096 skipCommentTokens (token);
10921097 bool successful = true ;
@@ -1158,6 +1163,7 @@ bool OurReader::readValue() {
11581163 lastValue_ = ¤tValue ();
11591164 }
11601165
1166+ --stackDepth_;
11611167 return successful;
11621168}
11631169
You can’t perform that action at this time.
0 commit comments