You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by ju...@apache.org on 2020/02/18 19:51:45 UTC

svn commit: r1874171 - in /subversion/trunk/subversion: include/private/ libsvn_client/ libsvn_delta/ libsvn_fs_fs/ libsvn_fs_x/ libsvn_ra/ libsvn_ra_serf/ libsvn_repos/ libsvn_subr/ libsvn_wc/

Author: julianfoad
Date: Tue Feb 18 19:51:45 2020
New Revision: 1874171

URL: http://svn.apache.org/viewvc?rev=1874171&view=rev
Log:
Complete the upgrade of array insert/delete functions.

For issue #4840 "Merge assertion failure in svn_sort__array_insert".

This changes all remaining callers, in other areas of Subversion, to use the
new array insert/delete functions that return standard Subversion errors if
inputs are out of bounds, and removes the old versions of those functions.
These are private functions so the public API is not affected.

* subversion/include/private/svn_sorts_private.h
* subversion/libsvn_subr/sorts.c
  (svn_sort__array_insert,
   svn_sort__array_delete): Remove.
  (svn_sort__array_insert2,
   svn_sort__array_delete2): Rewrite as the only version, instead of calling
    the old version. No functional change.

Elsewhere: update all callers.

Modified:
    subversion/trunk/subversion/include/private/svn_sorts_private.h
    subversion/trunk/subversion/libsvn_client/merge.c
    subversion/trunk/subversion/libsvn_client/repos_diff.c
    subversion/trunk/subversion/libsvn_delta/branch.c
    subversion/trunk/subversion/libsvn_fs_fs/cached_data.c
    subversion/trunk/subversion/libsvn_fs_fs/stats.c
    subversion/trunk/subversion/libsvn_fs_fs/temp_serializer.c
    subversion/trunk/subversion/libsvn_fs_x/cached_data.c
    subversion/trunk/subversion/libsvn_fs_x/revprops.c
    subversion/trunk/subversion/libsvn_fs_x/temp_serializer.c
    subversion/trunk/subversion/libsvn_ra/compat.c
    subversion/trunk/subversion/libsvn_ra_serf/inherited_props.c
    subversion/trunk/subversion/libsvn_ra_serf/lock.c
    subversion/trunk/subversion/libsvn_repos/authz.c
    subversion/trunk/subversion/libsvn_repos/fs-wrap.c
    subversion/trunk/subversion/libsvn_subr/mergeinfo.c
    subversion/trunk/subversion/libsvn_subr/sorts.c
    subversion/trunk/subversion/libsvn_wc/conflicts.c
    subversion/trunk/subversion/libsvn_wc/wc_db.c

Modified: subversion/trunk/subversion/include/private/svn_sorts_private.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/include/private/svn_sorts_private.h?rev=1874171&r1=1874170&r2=1874171&view=diff
==============================================================================
--- subversion/trunk/subversion/include/private/svn_sorts_private.h (original)
+++ subversion/trunk/subversion/include/private/svn_sorts_private.h Tue Feb 18 19:51:45 2020
@@ -120,15 +120,8 @@ svn_sort__array_lookup(const apr_array_h
  * @a insert_index, growing the array and shuffling existing elements along to
  * make room.
  *
- * @note Private. For use by Subversion's own code only.
- */
-void
-svn_sort__array_insert(apr_array_header_t *array,
-                       const void *new_element,
-                       int insert_index);
-
-/* Like svn_sort__array_insert() but raise an error if @a insert_index
- * is less than 0 or greater than the length of the array.
+ * Raise an error if @a insert_index is less than 0 or greater than the length
+ * of the array.
  *
  * @note Private. For use by Subversion's own code only.
  */
@@ -139,20 +132,10 @@ svn_sort__array_insert2(apr_array_header
 
 
 /* Remove @a elements_to_delete elements starting at @a delete_index from the
- * array @a arr. If @a delete_index is not a valid element of @a arr,
- * @a elements_to_delete is not greater than zero, or
- * @a delete_index + @a elements_to_delete is greater than @a arr->nelts,
- * then do nothing.
+ * array @a arr.
  *
- * @note Private. For use by Subversion's own code only.
- */
-void
-svn_sort__array_delete(apr_array_header_t *arr,
-                       int delete_index,
-                       int elements_to_delete);
-
-/* Like svn_sort__array_delete() but raise an error if attempting
- * to delete a range of elements that goes out of bounds of the array.
+ * Raise an error if the indexes to delete extends outside the array bounds
+ * or if @a elements_to_delete is not greater than zero.
  *
  * @note Private. For use by Subversion's own code only.
  */

Modified: subversion/trunk/subversion/libsvn_client/merge.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_client/merge.c?rev=1874171&r1=1874170&r2=1874171&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_client/merge.c (original)
+++ subversion/trunk/subversion/libsvn_client/merge.c Tue Feb 18 19:51:45 2020
@@ -5597,7 +5597,7 @@ svn_client__make_merge_conflict_error(sv
    defined in get_mergeinfo_paths().  Remove any paths absent from disk
    or scheduled for deletion from CHILDREN_WITH_MERGEINFO which are equal to
    or are descendants of TARGET_WCPATH by setting those children to NULL. */
-static void
+static svn_error_t *
 remove_absent_children(const char *target_wcpath,
                        apr_array_header_t *children_with_mergeinfo)
 {
@@ -5612,9 +5612,10 @@ remove_absent_children(const char *targe
       if ((child->absent || child->scheduled_for_deletion)
           && svn_dirent_is_ancestor(target_wcpath, child->abspath))
         {
-          svn_sort__array_delete(children_with_mergeinfo, i--, 1);
+          SVN_ERR(svn_sort__array_delete2(children_with_mergeinfo, i--, 1));
         }
     }
+  return SVN_NO_ERROR;
 }
 
 /* Helper for do_directory_merge() to handle the case where a merge editor
@@ -5629,14 +5630,14 @@ remove_absent_children(const char *targe
    MERGE_B->target->abspath, this must always be present in
    CHILDREN_WITH_MERGEINFO so this is never removed by this
    function. */
-static void
+static svn_error_t *
 remove_children_with_deleted_mergeinfo(merge_cmd_baton_t *merge_b,
                                        apr_array_header_t *children_with_mergeinfo)
 {
   int i;
 
   if (!merge_b->paths_with_deleted_mergeinfo)
-    return;
+    return SVN_NO_ERROR;
 
   /* CHILDREN_WITH_MERGEINFO[0] is the always the merge target
      so start at the first child. */
@@ -5647,9 +5648,10 @@ remove_children_with_deleted_mergeinfo(m
 
       if (svn_hash_gets(merge_b->paths_with_deleted_mergeinfo, child->abspath))
         {
-          svn_sort__array_delete(children_with_mergeinfo, i--, 1);
+          SVN_ERR(svn_sort__array_delete2(children_with_mergeinfo, i--, 1));
         }
     }
+  return SVN_NO_ERROR;
 }
 
 /* Helper for do_directory_merge().
@@ -6022,7 +6024,7 @@ slice_remaining_ranges(apr_array_header_
    If a range is removed from a child's remaining_ranges array, allocate the
    new remaining_ranges array in POOL.
  */
-static void
+static svn_error_t *
 remove_first_range_from_remaining_ranges(svn_revnum_t revision,
                                          apr_array_header_t
                                            *children_with_mergeinfo,
@@ -6043,10 +6045,11 @@ remove_first_range_from_remaining_ranges
             APR_ARRAY_IDX(child->remaining_ranges, 0, svn_merge_range_t *);
           if (first_range->end == revision)
             {
-              svn_sort__array_delete(child->remaining_ranges, 0, 1);
+              SVN_ERR(svn_sort__array_delete2(child->remaining_ranges, 0, 1));
             }
         }
     }
+  return SVN_NO_ERROR;
 }
 
 /* Get a file's content and properties from the repository.
@@ -7795,7 +7798,7 @@ do_file_merge(svn_mergeinfo_catalog_t re
              (This list is used from notify_merge_begin)
 
             Directory merges use remove_first_range_from_remaining_ranges() */
-          svn_sort__array_delete(ranges_to_merge, 0, 1);
+          SVN_ERR(svn_sort__array_delete2(ranges_to_merge, 0, 1));
         }
       merge_b->notify_begin.last_abspath = NULL;
     } /* !merge_b->record_only */
@@ -8548,8 +8551,8 @@ record_mergeinfo_for_dir_merge(svn_merge
   /* Remove absent children at or under MERGE_B->target->abspath from
      CHILDREN_WITH_MERGEINFO
      before we calculate the merges performed. */
-  remove_absent_children(merge_b->target->abspath,
-                         children_with_mergeinfo);
+  SVN_ERR(remove_absent_children(merge_b->target->abspath,
+                                 children_with_mergeinfo));
 
   /* Determine which subtrees of interest need mergeinfo recorded... */
   SVN_ERR(flag_subtrees_needing_mergeinfo(operative_merge, &range,
@@ -9546,12 +9549,12 @@ do_mergeinfo_aware_dir_merge(svn_mergein
                  to consider these subtrees for subsequent editor drives
                  nor do we want to record mergeinfo on them describing
                  the merge itself. */
-              remove_children_with_deleted_mergeinfo(
-                merge_b, children_with_mergeinfo);
+              SVN_ERR(remove_children_with_deleted_mergeinfo(
+                        merge_b, children_with_mergeinfo));
 
               /* Prepare for the next iteration (if any). */
-              remove_first_range_from_remaining_ranges(
-                end_rev, children_with_mergeinfo, scratch_pool);
+              SVN_ERR(remove_first_range_from_remaining_ranges(
+                        end_rev, children_with_mergeinfo, scratch_pool));
 
               /* If we raised any conflicts, break out and report how much
                  we have merged. */

Modified: subversion/trunk/subversion/libsvn_client/repos_diff.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_client/repos_diff.c?rev=1874171&r1=1874170&r2=1874171&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_client/repos_diff.c (original)
+++ subversion/trunk/subversion/libsvn_client/repos_diff.c Tue Feb 18 19:51:45 2020
@@ -384,7 +384,7 @@ get_file_from_ra(struct file_baton *fb,
      See https://issues.apache.org/jira/browse/SVN-3657#desc9 and
      http://svn.haxx.se/dev/archive-2010-08/0351.shtml for more details.
  */
-static void
+static svn_error_t *
 remove_non_prop_changes(apr_hash_t *pristine_props,
                         apr_array_header_t *changes)
 {
@@ -392,7 +392,7 @@ remove_non_prop_changes(apr_hash_t *pris
 
   /* For added nodes, there is nothing to filter. */
   if (apr_hash_count(pristine_props) == 0)
-    return;
+    return SVN_NO_ERROR;
 
   for (i = 0; i < changes->nelts; i++)
     {
@@ -406,11 +406,12 @@ remove_non_prop_changes(apr_hash_t *pris
           if (old_val && svn_string_compare(old_val, change->value))
             {
               /* Remove the matching change and re-check the current index */
-              svn_sort__array_delete(changes, i, 1);
+              SVN_ERR(svn_sort__array_delete2(changes, i, 1));
               i--;
             }
         }
     }
+  return SVN_NO_ERROR;
 }
 
 /* Get the empty file associated with the edit baton. This is cached so
@@ -1010,7 +1011,7 @@ close_file(void *file_baton,
         }
 
       if (fb->pristine_props)
-        remove_non_prop_changes(fb->pristine_props, fb->propchanges);
+        SVN_ERR(remove_non_prop_changes(fb->pristine_props, fb->propchanges));
 
       right_props = svn_prop__patch(fb->pristine_props, fb->propchanges,
                                     fb->pool);
@@ -1083,7 +1084,7 @@ close_directory(void *dir_baton,
 
       if (db->propchanges->nelts > 0)
         {
-          remove_non_prop_changes(pristine_props, db->propchanges);
+          SVN_ERR(remove_non_prop_changes(pristine_props, db->propchanges));
         }
 
       if (db->propchanges->nelts > 0 || db->added)

Modified: subversion/trunk/subversion/libsvn_delta/branch.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_delta/branch.c?rev=1874171&r1=1874170&r2=1874171&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_delta/branch.c (original)
+++ subversion/trunk/subversion/libsvn_delta/branch.c Tue Feb 18 19:51:45 2020
@@ -157,7 +157,7 @@ branch_txn_delete_branch(svn_branch__txn
 
       if (strcmp(b->bid, bid) == 0)
         {
-          svn_sort__array_delete(txn->priv->branches, i, 1);
+          SVN_ERR(svn_sort__array_delete2(txn->priv->branches, i, 1));
           break;
         }
     }

Modified: subversion/trunk/subversion/libsvn_fs_fs/cached_data.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_fs_fs/cached_data.c?rev=1874171&r1=1874170&r2=1874171&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_fs_fs/cached_data.c (original)
+++ subversion/trunk/subversion/libsvn_fs_fs/cached_data.c Tue Feb 18 19:51:45 2020
@@ -2337,7 +2337,7 @@ svn_fs_fs__get_contents_from_file(svn_st
                              rb->filehandle_pool));
 
       /* Insert the access to REP as the first element of the delta chain. */
-      svn_sort__array_insert(rb->rs_list, &rs, 0);
+      SVN_ERR(svn_sort__array_insert2(rb->rs_list, &rs, 0));
     }
 
   /* Now, the baton is complete and we can assemble the stream around it. */

Modified: subversion/trunk/subversion/libsvn_fs_fs/stats.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_fs_fs/stats.c?rev=1874171&r1=1874170&r2=1874171&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_fs_fs/stats.c (original)
+++ subversion/trunk/subversion/libsvn_fs_fs/stats.c Tue Feb 18 19:51:45 2020
@@ -488,7 +488,7 @@ parse_representation(rep_stats_t **repre
             }
         }
 
-      svn_sort__array_insert(revision_info->representations, &result, idx);
+      SVN_ERR(svn_sort__array_insert2(revision_info->representations, &result, idx));
     }
 
   *representation = result;

Modified: subversion/trunk/subversion/libsvn_fs_fs/temp_serializer.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_fs_fs/temp_serializer.c?rev=1874171&r1=1874170&r2=1874171&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_fs_fs/temp_serializer.c (original)
+++ subversion/trunk/subversion/libsvn_fs_fs/temp_serializer.c Tue Feb 18 19:51:45 2020
@@ -1013,13 +1013,13 @@ slowly_replace_dir_entry(void **data,
         APR_ARRAY_IDX(entries, idx, svn_fs_dirent_t *)
           = replace_baton->new_entry;
       else
-        svn_sort__array_insert(entries, &replace_baton->new_entry, idx);
+        SVN_ERR(svn_sort__array_insert2(entries, &replace_baton->new_entry, idx));
     }
   else
     {
       /* Remove the old ENTRY. */
       if (entry)
-        svn_sort__array_delete(entries, idx, 1);
+        SVN_ERR(svn_sort__array_delete2(entries, idx, 1));
     }
 
   return svn_fs_fs__serialize_dir_entries(data, data_len, dir, pool);

Modified: subversion/trunk/subversion/libsvn_fs_x/cached_data.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_fs_x/cached_data.c?rev=1874171&r1=1874170&r2=1874171&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_fs_x/cached_data.c (original)
+++ subversion/trunk/subversion/libsvn_fs_x/cached_data.c Tue Feb 18 19:51:45 2020
@@ -2229,7 +2229,7 @@ svn_fs_x__get_contents_from_file(svn_str
                              rb->filehandle_pool, rb->scratch_pool));
 
       /* Insert the access to REP as the first element of the delta chain. */
-      svn_sort__array_insert(rb->rs_list, &rs, 0);
+      SVN_ERR(svn_sort__array_insert2(rb->rs_list, &rs, 0));
     }
 
   /* Now, the baton is complete and we can assemble the stream around it. */

Modified: subversion/trunk/subversion/libsvn_fs_x/revprops.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_fs_x/revprops.c?rev=1874171&r1=1874170&r2=1874171&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_fs_x/revprops.c (original)
+++ subversion/trunk/subversion/libsvn_fs_x/revprops.c Tue Feb 18 19:51:45 2020
@@ -1203,7 +1203,7 @@ repack_file_open(apr_file_t **file,
   if (revprops->entry.start_rev == start_rev)
     APR_ARRAY_IDX(revprops->manifest, idx, manifest_entry_t) = new_entry;
   else
-    svn_sort__array_insert(revprops->manifest, &new_path, idx + 1);
+    SVN_ERR(svn_sort__array_insert2(revprops->manifest, &new_path, idx + 1));
 
   /* open the file */
   new_path = get_revprop_pack_filepath(revprops, &new_entry, scratch_pool);

Modified: subversion/trunk/subversion/libsvn_fs_x/temp_serializer.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_fs_x/temp_serializer.c?rev=1874171&r1=1874170&r2=1874171&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_fs_x/temp_serializer.c (original)
+++ subversion/trunk/subversion/libsvn_fs_x/temp_serializer.c Tue Feb 18 19:51:45 2020
@@ -925,13 +925,13 @@ slowly_replace_dir_entry(void **data,
         APR_ARRAY_IDX(entries, idx, svn_fs_x__dirent_t *)
           = replace_baton->new_entry;
       else
-        svn_sort__array_insert(entries, &replace_baton->new_entry, idx);
+        SVN_ERR(svn_sort__array_insert2(entries, &replace_baton->new_entry, idx));
     }
   else
     {
       /* Remove the old ENTRY. */
       if (entry)
-        svn_sort__array_delete(entries, idx, 1);
+        SVN_ERR(svn_sort__array_delete2(entries, idx, 1));
     }
 
   return svn_fs_x__serialize_dir_entries(data, data_len, dir, pool);

Modified: subversion/trunk/subversion/libsvn_ra/compat.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_ra/compat.c?rev=1874171&r1=1874170&r2=1874171&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_ra/compat.c (original)
+++ subversion/trunk/subversion/libsvn_ra/compat.c Tue Feb 18 19:51:45 2020
@@ -942,7 +942,7 @@ svn_ra__get_inherited_props_walk(svn_ra_
                                                          parent_url,
                                                          result_pool);
           new_iprop->prop_hash = final_hash;
-          svn_sort__array_insert(*inherited_props, &new_iprop, 0);
+          SVN_ERR(svn_sort__array_insert2(*inherited_props, &new_iprop, 0));
         }
     }
 

Modified: subversion/trunk/subversion/libsvn_ra_serf/inherited_props.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_ra_serf/inherited_props.c?rev=1874171&r1=1874170&r2=1874171&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_ra_serf/inherited_props.c (original)
+++ subversion/trunk/subversion/libsvn_ra_serf/inherited_props.c Tue Feb 18 19:51:45 2020
@@ -340,7 +340,7 @@ get_iprops_via_more_requests(svn_ra_sess
       new_iprop = apr_palloc(result_pool, sizeof(*new_iprop));
       new_iprop->path_or_url = apr_pstrdup(result_pool, rq->relpath);
       new_iprop->prop_hash = svn_prop_hash_dup(node_props, result_pool);
-      svn_sort__array_insert(*iprops, &new_iprop, 0);
+      SVN_ERR(svn_sort__array_insert2(*iprops, &new_iprop, 0));
     }
 
   return SVN_NO_ERROR;

Modified: subversion/trunk/subversion/libsvn_ra_serf/lock.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_ra_serf/lock.c?rev=1874171&r1=1874170&r2=1874171&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_ra_serf/lock.c (original)
+++ subversion/trunk/subversion/libsvn_ra_serf/lock.c Tue Feb 18 19:51:45 2020
@@ -354,7 +354,7 @@ run_locks(svn_ra_serf__session_t *sess,
               SVN_ERR(cb_err);
 
               waittime_left = sess->timeout;
-              svn_sort__array_delete(lock_ctxs, i, 1);
+              SVN_ERR(svn_sort__array_delete2(lock_ctxs, i, 1));
               i--;
 
               svn_pool_destroy(ctx->pool);

Modified: subversion/trunk/subversion/libsvn_repos/authz.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_repos/authz.c?rev=1874171&r1=1874170&r2=1874171&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_repos/authz.c (original)
+++ subversion/trunk/subversion/libsvn_repos/authz.c Tue Feb 18 19:51:45 2020
@@ -369,7 +369,7 @@ ensure_node_in_array(apr_array_header_t
    * Create one and insert it into the sorted array. */
   entry.node = create_node(segment, result_pool);
   entry.next = NULL;
-  svn_sort__array_insert(*array, &entry, idx);
+  svn_error_clear(svn_sort__array_insert2(*array, &entry, idx));
 
   return entry.node;
 }

Modified: subversion/trunk/subversion/libsvn_repos/fs-wrap.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_repos/fs-wrap.c?rev=1874171&r1=1874170&r2=1874171&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_repos/fs-wrap.c (original)
+++ subversion/trunk/subversion/libsvn_repos/fs-wrap.c Tue Feb 18 19:51:45 2020
@@ -1106,7 +1106,7 @@ svn_repos_fs_get_inherited_props(apr_arr
                 apr_pstrdup(result_pool, parent_path + 1);
               i_props->prop_hash = parent_properties;
               /* Build the output array in depth-first order. */
-              svn_sort__array_insert(inherited_props, &i_props, 0);
+              SVN_ERR(svn_sort__array_insert2(inherited_props, &i_props, 0));
             }
         }
     }

Modified: subversion/trunk/subversion/libsvn_subr/mergeinfo.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_subr/mergeinfo.c?rev=1874171&r1=1874170&r2=1874171&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_subr/mergeinfo.c (original)
+++ subversion/trunk/subversion/libsvn_subr/mergeinfo.c Tue Feb 18 19:51:45 2020
@@ -706,7 +706,7 @@ svn_rangelist__canonicalize(svn_rangelis
           if (lastrange->inheritable == range->inheritable)
             {
               lastrange->end = MAX(range->end, lastrange->end);
-              svn_sort__array_delete(rangelist, i, 1);
+              SVN_ERR(svn_sort__array_delete2(rangelist, i, 1));
               i--;
             }
         }

Modified: subversion/trunk/subversion/libsvn_subr/sorts.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_subr/sorts.c?rev=1874171&r1=1874170&r2=1874171&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_subr/sorts.c (original)
+++ subversion/trunk/subversion/libsvn_subr/sorts.c Tue Feb 18 19:51:45 2020
@@ -301,15 +301,20 @@ svn_sort__array_lookup(const apr_array_h
   return compare_func(result, key) ? NULL : result;
 }
 
-void
-svn_sort__array_insert(apr_array_header_t *array,
-                       const void *new_element,
-                       int insert_index)
+svn_error_t *
+svn_sort__array_insert2(apr_array_header_t *array,
+                        const void *new_element,
+                        int insert_index)
 {
   int elements_to_move;
   char *new_position;
 
-  assert(0 <= insert_index && insert_index <= array->nelts);
+  if (insert_index < 0 || insert_index > array->nelts)
+    return svn_error_createf(SVN_ERR_INCORRECT_PARAMS, NULL,
+                             _("svn_sort__array_insert2: Attempted insert "
+                               "at index %d in array length %d"),
+                             insert_index, array->nelts);
+
   elements_to_move = array->nelts - insert_index;  /* before bumping nelts */
 
   /* Grow the array, allocating a new space at the end. Note: this can
@@ -324,47 +329,9 @@ svn_sort__array_insert(apr_array_header_
 
   /* Copy in the new element */
   memcpy(new_position, new_element, array->elt_size);
-}
-
-svn_error_t *
-svn_sort__array_insert2(apr_array_header_t *array,
-                        const void *new_element,
-                        int insert_index)
-{
-  if (insert_index < 0 || insert_index > array->nelts)
-    return svn_error_createf(SVN_ERR_INCORRECT_PARAMS, NULL,
-                             _("svn_sort__array_insert2: Attempted insert "
-                               "at index %d in array length %d"),
-                             insert_index, array->nelts);
-  svn_sort__array_insert(array, new_element, insert_index);
   return SVN_NO_ERROR;
 }
 
-void
-svn_sort__array_delete(apr_array_header_t *arr,
-                       int delete_index,
-                       int elements_to_delete)
-{
-  /* Do we have a valid index and are there enough elements? */
-  if (delete_index >= 0
-      && delete_index < arr->nelts
-      && elements_to_delete > 0
-      && (arr->nelts - delete_index) >= elements_to_delete)
-    {
-      /* If we are not deleting a block of elements that extends to the end
-         of the array, then we need to move the remaining elements to keep
-         the array contiguous. */
-      if ((elements_to_delete + delete_index) < arr->nelts)
-        memmove(
-          arr->elts + arr->elt_size * delete_index,
-          arr->elts + (arr->elt_size * (delete_index + elements_to_delete)),
-          arr->elt_size * (arr->nelts - elements_to_delete - delete_index));
-
-      /* Delete the last ELEMENTS_TO_DELETE elements. */
-      arr->nelts -= elements_to_delete;
-    }
-}
-
 svn_error_t *
 svn_sort__array_delete2(apr_array_header_t *arr,
                         int delete_index,
@@ -378,7 +345,18 @@ svn_sort__array_delete2(apr_array_header
                              _("svn_sort__array_delete2: Attempted delete "
                                "at index %d, %d elements, in array length %d"),
                              delete_index, elements_to_delete, arr->nelts);
-  svn_sort__array_delete(arr, delete_index, elements_to_delete);
+
+  /* If we are deleting a block of elements that does not extend to the end
+     of the array, then we need to move the remaining elements to keep
+     the array contiguous. */
+  if ((elements_to_delete + delete_index) < arr->nelts)
+    memmove(
+      arr->elts + arr->elt_size * delete_index,
+      arr->elts + (arr->elt_size * (delete_index + elements_to_delete)),
+      arr->elt_size * (arr->nelts - elements_to_delete - delete_index));
+
+  /* Delete the last ELEMENTS_TO_DELETE elements. */
+  arr->nelts -= elements_to_delete;
   return SVN_NO_ERROR;
 }
 

Modified: subversion/trunk/subversion/libsvn_wc/conflicts.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/conflicts.c?rev=1874171&r1=1874170&r2=1874171&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/conflicts.c (original)
+++ subversion/trunk/subversion/libsvn_wc/conflicts.c Tue Feb 18 19:51:45 2020
@@ -3965,8 +3965,8 @@ svn_wc__guess_incoming_move_target_nodes
         {
           insert_index = (*possible_targets)->nelts; /* append */
         }
-      svn_sort__array_insert(*possible_targets, &moved_to_abspath,
-                             insert_index);
+      SVN_ERR(svn_sort__array_insert2(*possible_targets, &moved_to_abspath,
+                                      insert_index));
     }
 
   svn_pool_destroy(iterpool);

Modified: subversion/trunk/subversion/libsvn_wc/wc_db.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/wc_db.c?rev=1874171&r1=1874170&r2=1874171&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc_db.c (original)
+++ subversion/trunk/subversion/libsvn_wc/wc_db.c Tue Feb 18 19:51:45 2020
@@ -8396,7 +8396,7 @@ delete_node(void *baton,
                                          scratch_pool, iterpool));
 
               if (!mn->local_relpath)
-                svn_sort__array_delete(moved_nodes, i--, 1);
+                SVN_ERR(svn_sort__array_delete2(moved_nodes, i--, 1));
             }
         }
 
@@ -10804,7 +10804,7 @@ db_read_inherited_props(apr_array_header
 
                   iprop_elt->prop_hash = node_props;
                   /* Build the output array in depth-first order. */
-                  svn_sort__array_insert(iprops, &iprop_elt, 0);
+                  SVN_ERR(svn_sort__array_insert2(iprops, &iprop_elt, 0));
                 }
             }
         }
@@ -10840,7 +10840,7 @@ db_read_inherited_props(apr_array_header
 
           /* If we didn't filter everything then keep this iprop. */
           if (apr_hash_count(cached_iprop->prop_hash))
-            svn_sort__array_insert(iprops, &cached_iprop, 0);
+            SVN_ERR(svn_sort__array_insert2(iprops, &cached_iprop, 0));
         }
     }