Author: brane
Date: Mon Dec 17 11:26:44 2018
New Revision: 1849080
URL: http://svn.apache.org/viewvc?rev=1849080&view=rev
Log:
Change a private function's signature to prevent potential assertions.
* subversion/include/svn_dirent_uri.h
(svn_relpath__internal_style): Change prototype so that the function can
return an error instead of aborting if anything goes wrong.
* subversion/libsvn_subr/dirent_uri.c
(svn_relpath__internal_style): Update the implementation.
* subversion/bindings/javahl/native/Path.cpp (Relpath::initfunc),
* subversion/svndumpfilter/svndumpfilter.c (sub_main),
* subversion/tests/libsvn_subr/dirent_uri-test.c (test_relpath_internal_style):
Updated all callers.
Modified:
subversion/trunk/subversion/bindings/javahl/native/Path.cpp
subversion/trunk/subversion/include/svn_dirent_uri.h
subversion/trunk/subversion/libsvn_subr/dirent_uri.c
subversion/trunk/subversion/svndumpfilter/svndumpfilter.c
subversion/trunk/subversion/tests/libsvn_subr/dirent_uri-test.c
Modified: subversion/trunk/subversion/bindings/javahl/native/Path.cpp
URL:
http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/javahl/native/Path.cpp?rev=1849080&r1=1849079&r2=1849080&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/javahl/native/Path.cpp (original)
+++ subversion/trunk/subversion/bindings/javahl/native/Path.cpp Mon Dec 17
11:26:44 2018
@@ -164,6 +164,7 @@ URL::initfunc(const char*& path, SVN::Po
svn_error_t*
Relpath::initfunc(const char*& path, SVN::Pool& pool)
{
- path = svn_relpath__internal_style(path, pool.getPool());
- return SVN_NO_ERROR;
+ apr_pool_t *const p = pool.getPool();
+ return svn_error_trace(
+ svn_relpath__internal_style(&path, path, p, p));
}
Modified: subversion/trunk/subversion/include/svn_dirent_uri.h
URL:
http://svn.apache.org/viewvc/subversion/trunk/subversion/include/svn_dirent_uri.h?rev=1849080&r1=1849079&r2=1849080&view=diff
==============================================================================
--- subversion/trunk/subversion/include/svn_dirent_uri.h (original)
+++ subversion/trunk/subversion/include/svn_dirent_uri.h Mon Dec 17 11:26:44
2018
@@ -200,17 +200,21 @@ const char *
svn_dirent_local_style(const char *dirent,
apr_pool_t *result_pool);
-/** Convert @a relpath from the local style to the canonical internal style.
+/**
+ * Convert @a relpath from the local style to the canonical internal style.
* "Local style" means native path separators and "." for the empty path.
*
- * Allocate the result in @a result_pool.
+ * Allocates the results in @a result_pool. Uses @a scratch_pool for
+ * temporary allocations.
*
* @since New in 1.7.
+ * @since Signature changed in 1.12.
*/
-const char *
-svn_relpath__internal_style(const char *relpath,
- apr_pool_t *result_pool);
-
+svn_error_t *
+svn_relpath__internal_style(const char **internal_style_relpath,
+ const char *relpath,
+ apr_pool_t *result_pool,
+ apr_pool_t *scratch_pool);
/** Join a base dirent (@a base) with a component (@a component).
*
Modified: subversion/trunk/subversion/libsvn_subr/dirent_uri.c
URL:
http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_subr/dirent_uri.c?rev=1849080&r1=1849079&r2=1849080&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_subr/dirent_uri.c (original)
+++ subversion/trunk/subversion/libsvn_subr/dirent_uri.c Mon Dec 17 11:26:44
2018
@@ -934,14 +934,18 @@ svn_dirent_local_style(const char *diren
return dirent;
}
-const char *
-svn_relpath__internal_style(const char *relpath,
- apr_pool_t *pool)
+svn_error_t *
+svn_relpath__internal_style(const char **internal_style_relpath,
+ const char *relpath,
+ apr_pool_t *result_pool,
+ apr_pool_t *scratch_pool)
{
- return svn_relpath_canonicalize(internal_style(relpath, pool), pool);
+ return svn_error_trace(
+ svn_relpath_canonicalize_safe(internal_style_relpath, NULL,
+ internal_style(relpath, scratch_pool),
+ result_pool, scratch_pool));
}
-
/* We decided against using apr_filepath_root here because of the negative
performance impact (creating a pool and converting strings ). */
svn_boolean_t
Modified: subversion/trunk/subversion/svndumpfilter/svndumpfilter.c
URL:
http://svn.apache.org/viewvc/subversion/trunk/subversion/svndumpfilter/svndumpfilter.c?rev=1849080&r1=1849079&r2=1849080&view=diff
==============================================================================
--- subversion/trunk/subversion/svndumpfilter/svndumpfilter.c (original)
+++ subversion/trunk/subversion/svndumpfilter/svndumpfilter.c Mon Dec 17
11:26:44 2018
@@ -1467,7 +1467,7 @@ sub_main(int *exit_code, int argc, const
/* Ensure that each prefix is UTF8-encoded, in internal
style, and absolute. */
SVN_ERR(svn_utf_cstring_to_utf8(&prefix, os->argv[i], pool));
- prefix = svn_relpath__internal_style(prefix, pool);
+ SVN_ERR(svn_relpath__internal_style(&prefix, prefix, pool, pool));
if (prefix[0] != '/')
prefix = apr_pstrcat(pool, "/", prefix, SVN_VA_NULL);
APR_ARRAY_PUSH(opt_state.prefixes, const char *) = prefix;
Modified: subversion/trunk/subversion/tests/libsvn_subr/dirent_uri-test.c
URL:
http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/libsvn_subr/dirent_uri-test.c?rev=1849080&r1=1849079&r2=1849080&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/libsvn_subr/dirent_uri-test.c (original)
+++ subversion/trunk/subversion/tests/libsvn_subr/dirent_uri-test.c Mon Dec 17
11:26:44 2018
@@ -2331,7 +2331,8 @@ test_relpath_internal_style(apr_pool_t *
for (i = 0; i < COUNT_OF(tests); i++)
{
- const char *internal = svn_relpath__internal_style(tests[i].path, pool);
+ const char *internal;
+ SVN_ERR(svn_relpath__internal_style(&internal, tests[i].path, pool,
pool));
if (strcmp(internal, tests[i].result))
return svn_error_createf(SVN_ERR_TEST_FAILED, NULL,