# HG changeset patch # User Sebastian Brannstrom # Date 1289910107 0 # Node ID f015466e664252914a251a2e415de90c02e04546 # Parent 3317b29a19f13d3ee033030e9b38b1f7d8bbd2e5 Fix for bug 3942 diff -r 3317b29a19f1 -r f015466e6642 engine/src/PodcastUtils.cpp --- a/engine/src/PodcastUtils.cpp Tue Nov 16 11:34:24 2010 +0000 +++ b/engine/src/PodcastUtils.cpp Tue Nov 16 12:21:47 2010 +0000 @@ -118,8 +118,9 @@ DP(" change HTML encoded chars to unicode"); startPos = str.Locate('&'); endPos = str.Locate(';'); - while (startPos != KErrNotFound && endPos != KErrNotFound && endPos > startPos) + while (startPos != KErrNotFound && endPos != KErrNotFound && endPos > startPos && endPos < str.Length()) { +// DP2("startPos=%d, endPos=%d", startPos, endPos); TPtrC ptr(str.Mid(startPos+1, endPos-startPos)); // check for whitespace if (ptr.Locate(' ') == KErrNotFound) @@ -162,10 +163,9 @@ _LIT(KQuot, "quot;"); _LIT(KNbsp, "nbsp;"); _LIT(KCopy, "copy;"); - + // copy start of string tmp.Copy(str.Left(startPos)); - if (ptr.CompareF(KAmp) == 0) { tmp.Append('&'); @@ -182,27 +182,27 @@ { tmp.Append('\xA9'); } - // copy end of string tmp.Append(str.Mid(endPos+1)); str.Copy(tmp); } } - TInt newPos = str.Mid(startPos+1).Locate('&'); - - if (newPos != KErrNotFound) - { - startPos = startPos+1 + newPos; - endPos = str.Locate(';'); - } - else - { - startPos = KErrNotFound; - endPos = KErrNotFound; + if (startPos+1 <= str.Length()) { + TInt newPos = str.Mid(startPos+1).Locate('&'); + DP("two"); + if (newPos != KErrNotFound) + { + startPos = startPos+1 + newPos; + endPos = str.Locate(';'); + } + else + { + startPos = KErrNotFound; + endPos = KErrNotFound; + } } } - CleanupStack::PopAndDestroy(tmpBuf); if(str.Length()>1)