aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/compiler/qv4codegen_p.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/qml/compiler/qv4codegen_p.h')
-rw-r--r--src/qml/compiler/qv4codegen_p.h27
1 files changed, 26 insertions, 1 deletions
diff --git a/src/qml/compiler/qv4codegen_p.h b/src/qml/compiler/qv4codegen_p.h
index 7630a1f71d..3f96afc7c2 100644
--- a/src/qml/compiler/qv4codegen_p.h
+++ b/src/qml/compiler/qv4codegen_p.h
@@ -682,7 +682,7 @@ public:
void handleCall(Reference &base, Arguments calldata, int slotForFunction, int slotForThisObject);
Arguments pushTemplateArgs(AST::TemplateLiteral *args);
- int createTemplateArray(AST::TemplateLiteral *t);
+ void createTemplateObject(AST::TemplateLiteral *t);
void setUseFastLookups(bool b) { useFastLookups = b; }
@@ -767,6 +767,31 @@ protected:
bool _onoff;
};
+ class RecursionDepthCheck {
+ public:
+ RecursionDepthCheck(Codegen *cg, const AST::SourceLocation &loc)
+ : _cg(cg)
+ {
+#ifdef QT_NO_DEBUG
+ const int depthLimit = 4000; // limit to ~1000 deep
+#else
+ const int depthLimit = 1000; // limit to ~250 deep
+#endif // QT_NO_DEBUG
+
+ ++_cg->_recursionDepth;
+ if (_cg->_recursionDepth > depthLimit)
+ _cg->throwSyntaxError(loc, QStringLiteral("Maximum statement or expression depth exceeded"));
+ }
+
+ ~RecursionDepthCheck()
+ { --_cg->_recursionDepth; }
+
+ private:
+ Codegen *_cg;
+ };
+ int _recursionDepth = 0;
+ friend class RecursionDepthCheck;
+
private:
VolatileMemoryLocations scanVolatileMemoryLocations(AST::Node *ast) const;
void handleConstruct(const Reference &base, AST::ArgumentList *args);