$include_dir="/home/hyper-archives/boost-commit/include"; include("$include_dir/msg-header.inc") ?>
Subject: [Boost-commit] svn:boost r80279 - in trunk/libs/filesystem: doc src test
From: bdawes_at_[hidden]
Date: 2012-08-28 08:57:03
Author: bemandawes
Date: 2012-08-28 08:57:02 EDT (Tue, 28 Aug 2012)
New Revision: 80279
URL: http://svn.boost.org/trac/boost/changeset/80279
Log:
Fix #7239, Stack overflow when calling create_directories(":D"). The reported problem was a symptom of an internal bug that caused path::filename() and path::parent_path() to fail on Windows for path(":"), and that in turn caused other functions that depend on filename() or parent_path() to fail, such as create_directories().
Text files modified: 
   trunk/libs/filesystem/doc/release_history.html |    12 +++++++++++-                            
   trunk/libs/filesystem/src/operations.cpp       |     1 +                                       
   trunk/libs/filesystem/src/path.cpp             |     2 +-                                      
   trunk/libs/filesystem/test/path_test.cpp       |    21 +++++++++++++++++++++                   
   4 files changed, 34 insertions(+), 2 deletions(-)
Modified: trunk/libs/filesystem/doc/release_history.html
==============================================================================
--- trunk/libs/filesystem/doc/release_history.html	(original)
+++ trunk/libs/filesystem/doc/release_history.html	2012-08-28 08:57:02 EDT (Tue, 28 Aug 2012)
@@ -36,6 +36,16 @@
   </tr>
 </table>
 
+<h2>1.52.0</h2>
+<ul>
+  <li>Fix #7239, Stack 
+  overflow when calling <code>create_directories(":D")</code>. The reported 
+  problem was a symptom of an internal bug that caused <code>path::filename()</code> 
+  and <code>path::parent_path()</code> to fail on Windows for <code>path(":")</code>, 
+  and that in turn caused other functions that depend on <code>filename()</code> 
+  or <code>parent_path()</code> to fail, such as <code>create_directories()</code>.</li>
+</ul>
+
 <h2>1.51.0</h2>
 <ul>
   <li>Add begin() and end() non-member functions for directory_iterator and 
@@ -181,7 +191,7 @@
 </ul>
 <hr>
 <p>Revised
-<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->13 July, 2012<!--webbot bot="Timestamp" endspan i-checksum="21091" --></p>
+<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->28 August, 2012<!--webbot bot="Timestamp" endspan i-checksum="34454" --></p>
 <p>© Copyright Beman Dawes, 2011</p>
 <p> Use, modification, and distribution are subject to the Boost Software 
 License, Version 1.0. See <a href="http://www.boost.org/LICENSE_1_0.txt">
Modified: trunk/libs/filesystem/src/operations.cpp
==============================================================================
--- trunk/libs/filesystem/src/operations.cpp	(original)
+++ trunk/libs/filesystem/src/operations.cpp	2012-08-28 08:57:02 EDT (Tue, 28 Aug 2012)
@@ -927,6 +927,7 @@
     }
 
     path parent = p.parent_path();
+    BOOST_ASSERT_MSG(parent != p, "internal error: p == p.parent_path()");
     if (!parent.empty())
     {
       // determine if the parent exists
Modified: trunk/libs/filesystem/src/path.cpp
==============================================================================
--- trunk/libs/filesystem/src/path.cpp	(original)
+++ trunk/libs/filesystem/src/path.cpp	2012-08-28 08:57:02 EDT (Tue, 28 Aug 2012)
@@ -510,7 +510,7 @@
     size_type pos(str.find_last_of(separators, end_pos-1));
 
 #   ifdef BOOST_WINDOWS_API
-    if (pos == string_type::npos)
+    if (pos == string_type::npos && end_pos > 1)
       pos = str.find_last_of(colon, end_pos-2);
 #   endif
 
Modified: trunk/libs/filesystem/test/path_test.cpp
==============================================================================
--- trunk/libs/filesystem/test/path_test.cpp	(original)
+++ trunk/libs/filesystem/test/path_test.cpp	2012-08-28 08:57:02 EDT (Tue, 28 Aug 2012)
@@ -1117,6 +1117,27 @@
     BOOST_TEST(p.has_parent_path());
     BOOST_TEST(p.is_absolute());
 
+    //  ticket 2739, infinite recursion leading to stack overflow, was caused
+    //  by failure to handle this case correctly on Windows.
+    p = path(":"); 
+    PATH_TEST_EQ(p.parent_path().string(), "");
+    PATH_TEST_EQ(p.filename(), ":");
+    BOOST_TEST(!p.has_parent_path());
+    BOOST_TEST(p.has_filename());
+
+    //  test some similar cases that both POSIX and Windows should handle identically
+    p = path("c:"); 
+    PATH_TEST_EQ(p.parent_path().string(), "");
+    PATH_TEST_EQ(p.filename(), "c:");
+    BOOST_TEST(!p.has_parent_path());
+    BOOST_TEST(p.has_filename());
+    p = path("cc:"); 
+    PATH_TEST_EQ(p.parent_path().string(), "");
+    PATH_TEST_EQ(p.filename(), "cc:");
+    BOOST_TEST(!p.has_parent_path());
+    BOOST_TEST(p.has_filename());
+ 
+    //  Windows specific tests
     if (platform == "Windows")
     {