subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From stef...@apache.org
Subject svn commit: r1648612 - /subversion/trunk/subversion/libsvn_fs_fs/tree.c
Date Tue, 30 Dec 2014 22:26:17 GMT
Author: stefan2
Date: Tue Dec 30 22:26:17 2014
New Revision: 1648612

URL: http://svn.apache.org/r1648612
Log:
Follow-up to r1648591: Fix a similar segfault in the DAG walk code.

* subversion/libsvn_fs_fs/tree.c
  (open_path): We must always take the iteration start node HERE from
               the node path walked so far.  CHILD may live in ITERPOOL
               and must never be directly assigned to HERE anymore.
               This actually simplifies the iteration logic.

Modified:
    subversion/trunk/subversion/libsvn_fs_fs/tree.c

Modified: subversion/trunk/subversion/libsvn_fs_fs/tree.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_fs_fs/tree.c?rev=1648612&r1=1648611&r2=1648612&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_fs_fs/tree.c (original)
+++ subversion/trunk/subversion/libsvn_fs_fs/tree.c Tue Dec 30 22:26:17 2014
@@ -1020,15 +1020,12 @@ open_path(parent_path_t **parent_path_p,
       path_so_far->len += strlen(entry) + 1;
       path_so_far->data[path_so_far->len] = '\0';
 
-      if (*entry == '\0')
-        {
-          /* Given the behavior of svn_fs__next_entry_name(), this
-             happens when the path either starts or ends with a slash.
-             In either case, we stay put: the current directory stays
-             the same, and we add nothing to the parent path. */
-          child = here;
-        }
-      else
+      /* Given the behavior of svn_fs__next_entry_name(), ENTRY may be an
+         empty string when the path either starts or ends with a slash.
+         In either case, we stay put: the current directory stays the
+         same, and we add nothing to the parent path.  We only need to
+         process non-empty path segments. */
+      if (*entry != '\0')
         {
           copy_id_inherit_t inherit;
           const char *copy_path = NULL;
@@ -1076,12 +1073,8 @@ open_path(parent_path_t **parent_path_p,
 
           if (flags & open_path_node_only)
             {
-              /* Shortcut: the caller only wants the final DAG node.
-                 Make sure CHILD, which will become HERE, and the node
-                 we will ultimately return survive the cleanup of
-                 ITERPOOL. */
-              child = svn_fs_fs__dag_copy_into_pool(child, pool);
-              parent_path->node = child;
+              /* Shortcut: the caller only wants the final DAG node. */
+              parent_path->node = svn_fs_fs__dag_copy_into_pool(child, pool);
             }
           else
             {
@@ -1112,7 +1105,10 @@ open_path(parent_path_t **parent_path_p,
                   apr_psprintf(iterpool, _("Failure opening '%s'"), path));
 
       rest = next;
-      here = child;
+
+      /* The NODE in PARENT_PATH equals CHILD but lives in POOL, i.e.
+       * it will survive the cleanup of ITERPOOL.*/
+      here = parent_path->node;
     }
 
   svn_pool_destroy(iterpool);



Mime
View raw message