For for a potential crash bug when a show URL does not contain a period symbian1
authorSebastian Brannstrom <sebastianb@symbian.org>
Mon, 25 Oct 2010 14:03:07 +0100
branchsymbian1
changeset 287 e6a88732eb8f
parent 284 69385a7c9810
child 288 757e84a30b9a
For for a potential crash bug when a show URL does not contain a period
engine/src/ShowEngine.cpp
--- a/engine/src/ShowEngine.cpp	Sun Oct 24 01:27:31 2010 +0100
+++ b/engine/src/ShowEngine.cpp	Mon Oct 25 14:03:07 2010 +0100
@@ -190,13 +190,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);