aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/parser/qqmljsast_p.h
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@qt.io>2018-06-15 09:03:53 +0200
committerSimon Hausmann <simon.hausmann@qt.io>2018-06-25 20:04:05 +0000
commitd5adc61b1fe358f7ba5d3570305eaf0733426e2f (patch)
tree5f5d041a57d2c7d800acefc0ca9e5cb9b80b37d2 /src/qml/parser/qqmljsast_p.h
parentd26a497f3eaf37d6733b4ab1bceb2158eb127648 (diff)
Fix string memory leak in JavaScript AST
Commit 02252ae08d introduced a QString member in a JS memory pool class, which leaks unfortunately as the pool is not designed to call destructors of allocated types. Typically strings in the AST are derived from input and therefore a QStringRef is fine. The bindingIdentifier in the PatterElement however is sometimes synthesized, so a separate storage for dynamically allocated strings in the memory pool allows for using QStringRef again. Change-Id: I94d090df653d784c554452722b3b759031e4735b Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'src/qml/parser/qqmljsast_p.h')
-rw-r--r--src/qml/parser/qqmljsast_p.h6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/qml/parser/qqmljsast_p.h b/src/qml/parser/qqmljsast_p.h
index 66a4e357e9..67abbbf88a 100644
--- a/src/qml/parser/qqmljsast_p.h
+++ b/src/qml/parser/qqmljsast_p.h
@@ -671,7 +671,7 @@ public:
{ kind = K; }
PatternElement(const QStringRef &n, ExpressionNode *i = nullptr, Type t = Binding)
- : bindingIdentifier(n.toString()), initializer(i), type(t)
+ : bindingIdentifier(n), initializer(i), type(t)
{
Q_ASSERT(t >= RestElement);
kind = K;
@@ -705,7 +705,7 @@ public:
// attributes
SourceLocation identifierToken;
- QString bindingIdentifier;
+ QStringRef bindingIdentifier;
ExpressionNode *bindingTarget = nullptr;
ExpressionNode *initializer = nullptr;
Type type = Literal;
@@ -2212,7 +2212,7 @@ public:
SourceLocation lastSourceLocation() const override
{ return next ? next->lastSourceLocation() : element->lastSourceLocation(); }
- FormalParameterList *finish();
+ FormalParameterList *finish(MemoryPool *pool);
// attributes
PatternElement *element = nullptr;