Browse Source

2008-11-23 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>

	Fixed the bug that causes floating exception when -T option is
	used and no URIs are given.
	* src/download_helper.cc
	* test/DownloadHelperTest.cc
Tatsuhiro Tsujikawa 17 years ago
parent
commit
c104ac8319
3 changed files with 20 additions and 1 deletions
  1. 7 0
      ChangeLog
  2. 1 1
      src/download_helper.cc
  3. 12 0
      test/DownloadHelperTest.cc

+ 7 - 0
ChangeLog

@@ -1,3 +1,10 @@
+2008-11-23  Tatsuhiro Tsujikawa  <t-tujikawa@users.sourceforge.net>
+
+	Fixed the bug that causes floating exception when -T option is used and
+	no URIs are given.
+	* src/download_helper.cc
+	* test/DownloadHelperTest.cc
+
 2008-11-22  Ross Smith II  <aria2spam at smithii dot com>
 
 	Applied aria2-1.0.0-mingw-r5.patch to fix numerous compile/unit test 

+ 1 - 1
src/download_helper.cc

@@ -79,7 +79,7 @@ static void splitURI(std::deque<std::string>& result,
   size_t numURIs = std::distance(begin, end);
   if(numURIs >= numSplit) {
     result.insert(result.end(), begin, end);
-  } else {
+  } else if(numURIs > 0) {
     for(size_t i = 0; i < numSplit/numURIs; ++i) {
       result.insert(result.end(), begin, end);
     }

+ 12 - 0
test/DownloadHelperTest.cc

@@ -360,6 +360,18 @@ void DownloadHelperTest::testCreateRequestGroupForBitTorrent()
     }
     CPPUNIT_ASSERT_EQUAL((unsigned int)5, group->getNumConcurrentCommand());
   }
+  {
+    // no URIs are given
+    std::deque<SharedHandle<RequestGroup> > result;
+    std::deque<std::string> emptyURIs;
+    createRequestGroupForBitTorrent(result, &op, emptyURIs);
+
+    CPPUNIT_ASSERT_EQUAL((size_t)1, result.size());
+    SharedHandle<RequestGroup> group = result[0];
+    std::deque<std::string> uris;
+    group->getURIs(uris);
+    CPPUNIT_ASSERT_EQUAL((size_t)0, uris.size());
+  }
   op.put(PREF_FORCE_SEQUENTIAL, V_TRUE);
   {
     std::deque<SharedHandle<RequestGroup> > result;