Commit d1b17740 authored by Kamil Rojewski's avatar Kamil Rojewski
Browse files

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: default avatarJędrzej Nowacki <jedrzej.nowacki@digia.com>
Showing with 18 additions and 14 deletions
......@@ -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;
}
}
}
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment