diff options
author | Holger Hans Peter Freyther <holger@moiji-mobile.com> | 2014-07-20 16:42:59 +0200 |
---|---|---|
committer | Holger Freyther <holger+qt@freyther.de> | 2014-07-21 14:43:01 +0200 |
commit | a8a66e51ef5d9506a5458425c7e749935afa649d (patch) | |
tree | e05fa4bf39c993f3e6aed17fe505044c2e8f4e83 /src/qml/compiler | |
parent | 23e506fb3ea393e6ed1698923094000d6b640dac (diff) |
qml: Make ownership of CompiledUnit more clear
The coverity scan utility didn't understand the code flow and assumed
the compiledData would be leaked. Use a QScopedPointer and have the
::backendCompileStep() forward the ownership. From what I see the code
has not leaked memory.
Fixes: CID 10605, CID 10607
Change-Id: I7759f681871bbe12e2aa320a5f39c47c70f4e4e0
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'src/qml/compiler')
-rw-r--r-- | src/qml/compiler/qv4isel_moth.cpp | 7 | ||||
-rw-r--r-- | src/qml/compiler/qv4isel_moth_p.h | 2 |
2 files changed, 4 insertions, 5 deletions
diff --git a/src/qml/compiler/qv4isel_moth.cpp b/src/qml/compiler/qv4isel_moth.cpp index c684aa3e79..7c67ae2301 100644 --- a/src/qml/compiler/qv4isel_moth.cpp +++ b/src/qml/compiler/qv4isel_moth.cpp @@ -328,9 +328,8 @@ InstructionSelection::InstructionSelection(QQmlEnginePrivate *qmlEngine, QV4::Ex , _codeNext(0) , _codeEnd(0) , _currentStatement(0) -{ - compilationUnit = new CompilationUnit; -} + , compilationUnit(new CompilationUnit) +{} InstructionSelection::~InstructionSelection() { @@ -459,7 +458,7 @@ QV4::CompiledData::CompilationUnit *InstructionSelection::backendCompileStep() int i = 0; foreach (IR::Function *irFunction, irModule->functions) compilationUnit->codeRefs[i++] = codeRefs[irFunction]; - return compilationUnit; + return compilationUnit.take(); } void InstructionSelection::callValue(IR::Expr *value, IR::ExprList *args, IR::Expr *result) diff --git a/src/qml/compiler/qv4isel_moth_p.h b/src/qml/compiler/qv4isel_moth_p.h index 6f9f001f28..2fdb7c007c 100644 --- a/src/qml/compiler/qv4isel_moth_p.h +++ b/src/qml/compiler/qv4isel_moth_p.h @@ -184,7 +184,7 @@ private: QSet<IR::Jump *> _removableJumps; IR::Stmt *_currentStatement; - CompilationUnit *compilationUnit; + QScopedPointer<CompilationUnit> compilationUnit; QHash<IR::Function *, QByteArray> codeRefs; }; |