diff options
author | Simon Hausmann <simon.hausmann@qt.io> | 2018-06-15 09:03:53 +0200 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@qt.io> | 2018-06-25 20:04:05 +0000 |
commit | d5adc61b1fe358f7ba5d3570305eaf0733426e2f (patch) | |
tree | 5f5d041a57d2c7d800acefc0ca9e5cb9b80b37d2 /src/qml/compiler/qv4codegen.cpp | |
parent | d26a497f3eaf37d6733b4ab1bceb2158eb127648 (diff) | |
download | qtdeclarative-d5adc61b1fe358f7ba5d3570305eaf0733426e2f.tar.gz |
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/compiler/qv4codegen.cpp')
-rw-r--r-- | src/qml/compiler/qv4codegen.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/qml/compiler/qv4codegen.cpp b/src/qml/compiler/qv4codegen.cpp index fc2fb86666..9c00d660b0 100644 --- a/src/qml/compiler/qv4codegen.cpp +++ b/src/qml/compiler/qv4codegen.cpp @@ -472,7 +472,7 @@ void Codegen::variableDeclarationList(VariableDeclarationList *ast) Codegen::Reference Codegen::targetForPatternElement(AST::PatternElement *p) { if (!p->bindingIdentifier.isNull()) - return referenceForName(p->bindingIdentifier, true); + return referenceForName(p->bindingIdentifier.toString(), true); if (!p->bindingTarget || p->destructuringPattern()) return Codegen::Reference::fromStackSlot(this); Reference lhs = expression(p->bindingTarget); @@ -2656,7 +2656,7 @@ int Codegen::defineFunction(const QString &name, AST::Node *ast, Q_UNREACHABLE(); } - Reference arg = referenceForName(e->bindingIdentifier, true); + Reference arg = referenceForName(e->bindingIdentifier.toString(), true); if (e->type == PatternElement::RestElement) { Q_ASSERT(!formals->next); Instruction::CreateRestParameter rest; |