limit stackDepth
diff --git a/src/lib_json/json_reader.cpp b/src/lib_json/json_reader.cpp
index 95eb4b2..6cf23e3 100644
--- a/src/lib_json/json_reader.cpp
+++ b/src/lib_json/json_reader.cpp
@@ -1034,7 +1034,9 @@
   Location lastValueEnd_;
   Value* lastValue_;
   std::string commentsBefore_;
-  OurFeatures features_;
+  int stackDepth_;
+
+  OurFeatures const features_;
   bool collectComments_;
 };  // OurReader
 
@@ -1065,6 +1067,7 @@
     nodes_.pop();
   nodes_.push(&root);
 
+  stackDepth_ = 0;
   bool successful = readValue();
   Token token;
   skipCommentTokens(token);
@@ -1087,6 +1090,8 @@
 }
 
 bool OurReader::readValue() {
+  if (stackDepth_ >= features_.stackLimit_) throw std::runtime_error("Exceeded stackLimit in readValue().");
+  ++stackDepth_;
   Token token;
   skipCommentTokens(token);
   bool successful = true;
@@ -1158,6 +1163,7 @@
     lastValue_ = &currentValue();
   }
 
+  --stackDepth_;
   return successful;
 }