[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: [PATCH] error leak on performance branch

From: Hyrum K. Wright <hyrum_wright_at_mail.utexas.edu>
Date: Mon, 8 Nov 2010 06:56:16 -0600

On Sun, Nov 7, 2010 at 11:58 AM, Stefan Sperling <stsp_at_elego.de> wrote:
> [[[
> * subversion/libsvn_fs_util/caching.c
>  (svn_fs__get_global_membuffer_cache): Fix a possible error leak.
> ]]]
>
> Index: subversion/libsvn_fs_util/caching.c
> ===================================================================
> --- subversion/libsvn_fs_util/caching.c (revision 1032308)
> +++ subversion/libsvn_fs_util/caching.c (working copy)
> @@ -62,6 +62,7 @@ svn_fs__get_global_membuffer_cache(void)
>       /* auto-allocate cache*/
>       apr_allocator_t *allocator = NULL;
>       apr_pool_t *pool = NULL;
> +      svn_error_t *err;
>
>       if (apr_allocator_create(&allocator))
>         return NULL;
> @@ -75,12 +76,17 @@ svn_fs__get_global_membuffer_cache(void)
>       apr_allocator_max_free_set(allocator, 1);
>       pool = svn_pool_create_ex(NULL, allocator);
>
> -      svn_cache__membuffer_cache_create
> -          (&cache,
> -           (apr_size_t)cache_size,
> -           (apr_size_t)(cache_size / 16),
> -           ! svn_fs_get_cache_config()->single_threaded,
> -           pool);

If we're choosing to ignore the error above, you can just wrap the
entire call in an svn_error_clear(). No need to introduce and check a
temp variable.

> +      err = svn_cache__membuffer_cache_create
> +              (&cache,
> +               (apr_size_t)cache_size,
> +               (apr_size_t)(cache_size / 16),
> +               ! svn_fs_get_cache_config()->single_threaded,
> +               pool);
> +      if (err)
> +        {
> +          svn_error_clear(err);
> +          return NULL;
> +        }

Does this early return actually change functionality? If so, this
patch is about more than just fixing an error leak...

>     }
>
>   return cache;
>
Received on 2010-11-08 13:56:59 CET

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.