For for a potential crash bug when a show URL does not contain a period RCL_3
authorSebastian Brannstrom <sebastianb@symbian.org>
Mon, 25 Oct 2010 14:03:07 +0100
branchRCL_3
changeset 291 2f62fe179bbb
parent 290 0d5e69a7cda9
child 292 655dbce90b70
For for a potential crash bug when a show URL does not contain a period
engine/src/ShowEngine.cpp
--- a/engine/src/ShowEngine.cpp	Mon Oct 25 13:58:51 2010 +0100
+++ b/engine/src/ShowEngine.cpp	Mon Oct 25 14:03:07 2010 +0100
@@ -198,13 +198,25 @@
 	TFileName fileName;
 	PodcastUtils::FileNameFromUrl(info->Url(), fileName);
 	
-	TFileName extension;
-	extension.Copy(fileName.Mid(fileName.LocateReverse('.')));
-	DP1("extension=%S", &extension);
-		
 	TFileName newFilename;
-	newFilename.Format(_L("%u%S"), info->Uid(), &extension);
-	DP1("newFilename=%S", &newFilename);
+	
+	TInt periodPos = fileName.LocateReverse('.');
+
+	if (periodPos != -1)
+		{
+		// file extension (most likely) found
+		TFileName extension;
+		extension.Copy(fileName.Mid(periodPos));
+		DP1("extension=%S", &extension);
+			
+		newFilename.Format(_L("%u%S"), info->Uid(), &extension);
+		DP1("newFilename=%S", &newFilename);
+		} 
+	else
+		{
+		// no extension found, we'll have to rely on magic numbers
+		newFilename.Copy(fileName);
+		}
 			
 	relPath.Append(newFilename);
 	PodcastUtils::EnsureProperPathName(relPath);