From ca2b4d1ccabc3bccde4d146284b1cac39058e711 Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Sat, 17 Aug 2013 14:54:56 +0200 Subject: Fix invalid reads with strings It may happen that a dynamically created compilation unit disappears before any QV4::Strings it created. Those strings would still have a reference to the QString data in the compilation unit. I don't see a choice other than making a copy of the string data ;(. But this patch adds a flag that would allow for avoiding it if we happen to know that the compilation unit data is static. Change-Id: Ib35a4d2a566b301a25ffe56e392809e44e7b4ae8 Reviewed-by: Lars Knoll --- src/qml/jsruntime/qv4function.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/qml/jsruntime/qv4function.cpp') diff --git a/src/qml/jsruntime/qv4function.cpp b/src/qml/jsruntime/qv4function.cpp index 607d06756d..e989d31c1b 100644 --- a/src/qml/jsruntime/qv4function.cpp +++ b/src/qml/jsruntime/qv4function.cpp @@ -72,13 +72,13 @@ Function::Function(ExecutionEngine *engine, CompiledData::CompilationUnit *unit, formals.resize(compiledFunction->nFormals); const quint32 *formalsIndices = compiledFunction->formalsTable(); for (int i = 0; i < compiledFunction->nFormals; ++i) - formals[i] = engine->newString(unit->data->stringAt(formalsIndices[i])->qString()); + formals[i] = engine->newString(unit->data->stringAt(formalsIndices[i])); locals.resize(compiledFunction->nLocals); const quint32 *localsIndices = compiledFunction->localsTable(); for (int i = 0; i < compiledFunction->nLocals; ++i) - locals[i] = engine->newString(unit->data->stringAt(localsIndices[i])->qString()); + locals[i] = engine->newString(unit->data->stringAt(localsIndices[i])); } Function::~Function() -- cgit v1.2.3