Blob Blame History Raw
From 30c07792eda0ac656f5173852a059705d8b85163 Mon Sep 17 00:00:00 2001
From: Joris Guisson <joris.guisson@gmail.com>
Date: Mon, 24 Sep 2012 13:23:41 +0200
Subject: [PATCH 2/9] Backport to 1.3: Fix crash when preallocating diskspace
 when a file is enabled during the download of a torrent

CCBUG: 307178
---
 ChangeLog                          | 1 +
 src/diskio/multifilecache.cpp      | 3 ++-
 src/diskio/preallocationthread.cpp | 3 ++-
 3 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index c037d28..7ce9c53 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,6 @@
 Changes in 1.3.1:
 - Add workaround for broken handling of btrfs subvolumes by solid (306825)
+- Fix crash when preallocating diskspace when a file is enabled during the download of a torrent (307178) 
 
 Changes in 1.3:
 - Do not pass link local IPv6 addresses to ip parameter of tracker (305187)
diff --git a/src/diskio/multifilecache.cpp b/src/diskio/multifilecache.cpp
index ce19ffd..8e3d90f 100644
--- a/src/diskio/multifilecache.cpp
+++ b/src/diskio/multifilecache.cpp
@@ -783,7 +783,8 @@ namespace bt
 		while(i != files.end())
 		{
 			CacheFile::Ptr cf = i.value();
-			prealloc->add(cf);
+			if(cf)
+				prealloc->add(cf);
 			i++;
 		}
 	}
diff --git a/src/diskio/preallocationthread.cpp b/src/diskio/preallocationthread.cpp
index 1a8856c..914d859 100644
--- a/src/diskio/preallocationthread.cpp
+++ b/src/diskio/preallocationthread.cpp
@@ -51,7 +51,8 @@ namespace bt
 	
 	void PreallocationThread::add(CacheFile::Ptr cache_file)
 	{
-		todo.append(cache_file);
+		if(cache_file)
+			todo.append(cache_file);
 	}
 
 
-- 
1.8.0.2