From d5adc61b1fe358f7ba5d3570305eaf0733426e2f Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Fri, 15 Jun 2018 09:03:53 +0200 Subject: 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 --- src/qml/compiler/qv4compilerscanfunctions.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/qml/compiler/qv4compilerscanfunctions.cpp') diff --git a/src/qml/compiler/qv4compilerscanfunctions.cpp b/src/qml/compiler/qv4compilerscanfunctions.cpp index 7506b238f8..f3c1694b79 100644 --- a/src/qml/compiler/qv4compilerscanfunctions.cpp +++ b/src/qml/compiler/qv4compilerscanfunctions.cpp @@ -360,7 +360,7 @@ bool ScanFunctions::visit(Catch *ast) TemporaryBoolAssignment allowFuncDecls(_allowFuncDecls, _context->isStrict ? false : _allowFuncDecls); enterEnvironment(ast, ContextType::Block, QStringLiteral("%CatchBlock")); _context->isCatchBlock = true; - QString caughtVar = ast->patternElement->bindingIdentifier; + QString caughtVar = ast->patternElement->bindingIdentifier.toString(); if (caughtVar.isEmpty()) caughtVar = QStringLiteral("@caught"); _context->addLocalVar(caughtVar, Context::MemberType::VariableDefinition, VariableScope::Let); -- cgit v1.2.1