From a4eae8a44ca38739755ba8994251e2b120878ec8 Mon Sep 17 00:00:00 2001 From: mread Date: Fri, 26 Aug 2011 12:07:31 +0100 Subject: Fixed use of deleted object in XmlPatterns EvaluationCache This problem was shown up by the Ilta-Sanomat QML app on Symbian. Changes to the EvaluationCache class in 23267553627ac3c4cbcd918283bee8e665deeff9 meant that it was now trying to access the declaration object after it had been deleted. This change takes the data needed from the declaration object (1 bool) and stores that instead Task-number: QTTH-1492 Reviewed-by: Honglei Zhang --- src/xmlpatterns/expr/qevaluationcache.cpp | 5 ++--- src/xmlpatterns/expr/qevaluationcache_p.h | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/xmlpatterns/expr/qevaluationcache.cpp b/src/xmlpatterns/expr/qevaluationcache.cpp index 67109eb..3b6fc92 100644 --- a/src/xmlpatterns/expr/qevaluationcache.cpp +++ b/src/xmlpatterns/expr/qevaluationcache.cpp @@ -49,10 +49,9 @@ template EvaluationCache::EvaluationCache(const Expression::Ptr &op, const VariableDeclaration *varDecl, const VariableSlotID aSlot) : SingleContainer(op) - , m_declaration(varDecl) + , m_declarationUsedByMany(varDecl->usedByMany()) , m_varSlot(aSlot) { - Q_ASSERT(m_declaration); Q_ASSERT(m_varSlot > -1); } @@ -199,7 +198,7 @@ Expression::Ptr EvaluationCache::compress(const StaticContext::Ptr if(m_operand->is(IDRangeVariableReference)) return m_operand; - if(m_declaration->usedByMany()) + if (m_declarationUsedByMany) { /* If it's only an atomic value an EvaluationCache is overkill. However, * it's still needed for functions like fn:current-time() that must adhere to diff --git a/src/xmlpatterns/expr/qevaluationcache_p.h b/src/xmlpatterns/expr/qevaluationcache_p.h index 6080157..77d9c11 100644 --- a/src/xmlpatterns/expr/qevaluationcache_p.h +++ b/src/xmlpatterns/expr/qevaluationcache_p.h @@ -124,7 +124,7 @@ namespace QPatternist private: static DynamicContext::Ptr topFocusContext(const DynamicContext::Ptr &context); - const VariableDeclaration *m_declaration; + bool m_declarationUsedByMany; /** * This variable must not be called m_slot. If it so, a compiler bug on * HP-UX-aCC-64 is triggered in the constructor initializor. See the -- cgit v0.12