|
@@ -78,7 +78,15 @@ static constexpr aiImporterDesc desc = {
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
// ------------------------------------------------------------------------------------------------
|
|
// Recursive parsing of LWS files
|
|
// Recursive parsing of LWS files
|
|
-void LWS::Element::Parse(const char *&buffer, const char *end) {
|
|
|
|
|
|
+namespace {
|
|
|
|
+ constexpr int MAX_DEPTH = 1000; // Define the maximum depth allowed
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+void LWS::Element::Parse(const char *&buffer, const char *end, int depth) {
|
|
|
|
+ if (depth > MAX_DEPTH) {
|
|
|
|
+ throw std::runtime_error("Maximum recursion depth exceeded in LWS::Element::Parse");
|
|
|
|
+ }
|
|
|
|
+
|
|
for (; SkipSpacesAndLineEnd(&buffer, end); SkipLine(&buffer, end)) {
|
|
for (; SkipSpacesAndLineEnd(&buffer, end); SkipLine(&buffer, end)) {
|
|
|
|
|
|
// begin of a new element with children
|
|
// begin of a new element with children
|
|
@@ -121,7 +129,7 @@ void LWS::Element::Parse(const char *&buffer, const char *end) {
|
|
|
|
|
|
// parse more elements recursively
|
|
// parse more elements recursively
|
|
if (sub) {
|
|
if (sub) {
|
|
- children.back().Parse(buffer, end);
|
|
|
|
|
|
+ children.back().Parse(buffer, end, depth + 1);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|