subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From i...@apache.org
Subject svn commit: r1647372 - in /subversion/trunk/subversion: libsvn_subr/cache-membuffer.c tests/libsvn_subr/cache-test.c
Date Mon, 22 Dec 2014 18:48:31 GMT
Author: ivan
Date: Mon Dec 22 18:48:31 2014
New Revision: 1647372

URL: http://svn.apache.org/r1647372
Log:
Fix theoretical error leak returned from cache partial setter callback.

* subversion/libsvn_subr/cache-membuffer.c
  (membuffer_cache_set_partial_internal): Do not ignore error from partial 
   setter callback.
* subversion/tests/libsvn_subr/cache-test.c
  (test_membuffer_serializer_error_handling): Extend test to cover another 
   case.
  (raise_error_partial_setter_func): New helper for 
   test_membuffer_serializer_error_handling()

Modified:
    subversion/trunk/subversion/libsvn_subr/cache-membuffer.c
    subversion/trunk/subversion/tests/libsvn_subr/cache-test.c

Modified: subversion/trunk/subversion/libsvn_subr/cache-membuffer.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_subr/cache-membuffer.c?rev=1647372&r1=1647371&r2=1647372&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_subr/cache-membuffer.c (original)
+++ subversion/trunk/subversion/libsvn_subr/cache-membuffer.c Mon Dec 22 18:48:31 2014
@@ -2398,6 +2398,8 @@ membuffer_cache_set_partial_internal(svn
            * We better drop that.
            */
           drop_entry(cache, entry);
+
+          return err;
         }
       else
         {

Modified: subversion/trunk/subversion/tests/libsvn_subr/cache-test.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/libsvn_subr/cache-test.c?rev=1647372&r1=1647371&r2=1647372&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/libsvn_subr/cache-test.c (original)
+++ subversion/trunk/subversion/tests/libsvn_subr/cache-test.c Mon Dec 22 18:48:31 2014
@@ -222,6 +222,16 @@ raise_error_partial_getter_func(void **o
   return svn_error_create(APR_EGENERAL, NULL, NULL);
 }
 
+/* Implements svn_cache__partial_setter_func_t */
+static svn_error_t *
+raise_error_partial_setter_func(void **data,
+                                apr_size_t *data_len,
+                                void *baton,
+                                apr_pool_t *result_pool)
+{
+  return svn_error_create(APR_EGENERAL, NULL, NULL);
+}
+
 static svn_error_t *
 test_membuffer_serializer_error_handling(apr_pool_t *pool)
 {
@@ -261,6 +271,30 @@ test_membuffer_serializer_error_handling
                            NULL, pool),
     APR_EGENERAL);
 
+  /* Create a new cache. */
+  SVN_ERR(svn_cache__membuffer_cache_create(&membuffer, 10*1024, 1, 0,
+                                            TRUE, TRUE, pool));
+  SVN_ERR(svn_cache__create_membuffer_cache(&cache,
+                                            membuffer,
+                                            serialize_revnum,
+                                            deserialize_revnum,
+                                            APR_HASH_KEY_STRING,
+                                            "cache:",
+                                            SVN_CACHE__MEMBUFFER_DEFAULT_PRIORITY,
+                                            FALSE,
+                                            pool, pool));
+
+  /* Store one entry in cache. */
+  SVN_ERR(svn_cache__set(cache, "twenty", &twenty, pool));
+
+  /* Test setting data in cache using partial setter that
+     always raises an error. */
+  SVN_TEST_ASSERT_ERROR(
+    svn_cache__set_partial(cache, "twenty", 
+                           raise_error_partial_setter_func,
+                           NULL, pool),
+    APR_EGENERAL);
+
   return SVN_NO_ERROR;
 }
 



Mime
View raw message