summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorKamil Rojewski <kamil.rojewski@gmail.com>2014-08-13 10:38:38 +0200
committerKamil Rojewski <kamil.rojewski@gmail.com>2014-08-14 09:57:50 +0200
commitd1b17740ed4d9b1e3c3ad5898bb8259969dc77df (patch)
treeeb19372bc01bc39e0df6f4e89051fc6610862771 /src
parent7967dcfb45bce9307651d20856a0eccb31d20d60 (diff)
downloadqtxmlpatterns-d1b17740ed4d9b1e3c3ad5898bb8259969dc77df.tar.gz
fix for stack overflow
Recursion in item mapping iterator caused a stack overflow for large datasets. Task-number: QTBUG-40153 Change-Id: I693798de0ecfd3a920a3dd270172ce7ec3c13d8d Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@digia.com>
Diffstat (limited to 'src')
-rw-r--r--src/xmlpatterns/iterators/qitemmappingiterator_p.h32
1 files changed, 18 insertions, 14 deletions
diff --git a/src/xmlpatterns/iterators/qitemmappingiterator_p.h b/src/xmlpatterns/iterators/qitemmappingiterator_p.h
index 9dc3b45..3167bd7 100644
--- a/src/xmlpatterns/iterators/qitemmappingiterator_p.h
+++ b/src/xmlpatterns/iterators/qitemmappingiterator_p.h
@@ -115,24 +115,28 @@ namespace QPatternist
*/
virtual TResult next()
{
- const TSource sourceItem(m_it->next());
-
- if(qIsForwardIteratorEnd(sourceItem))
- {
- m_current = TResult();
- m_position = -1;
- return TResult();
- }
- else
+ while (true)
{
- m_current = m_mapper->mapToItem(sourceItem, m_context);
- if(qIsForwardIteratorEnd(m_current))
- return next(); /* The mapper returned null, so continue with the next in the source. */
- else
+ const TSource &sourceItem = m_it->next();
+ if (qIsForwardIteratorEnd(sourceItem))
{
- ++m_position;
+ m_current = TResult();
+ m_position = -1;
return m_current;
}
+ else
+ {
+ m_current = m_mapper->mapToItem(sourceItem, m_context);
+ if (qIsForwardIteratorEnd(m_current))
+ {
+ continue; /* The mapper returned null, so continue with the next in the source. */
+ }
+ else
+ {
+ ++m_position;
+ return m_current;
+ }
+ }
}
}