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

Re: [PATCH] issue #2662, yet another authz wildcards support patch...

From: Karl Fogel <kfogel_at_red-bean.com>
Date: Wed, 28 May 2008 12:11:05 -0400

Gerald Macinenti <gerald.macinenti_at_letitwave.fr> writes:
> --- subversion/libsvn_subr/config.c.orig
> +++ subversion/libsvn_subr/config.c
> @@ -356,6 +357,38 @@
> }
>
>
> +/* Find a matching section in the configuration with wildcard support
> + Return a pointer to a section in CFG, or NULL if it doesn't exist. */
> +static cfg_section_t *
> +find_section(svn_config_t *cfg, const char *section, apr_pool_t *pool)
> +{
> + apr_hash_index_t *sec_ndx;
> + apr_pool_t *iteration_pool;
> + cfg_section_t * sectionp = NULL;
> + int count = 0;

Oh, we traditionally call it "iter_pool". No big deal, and obviously we
could just tweak it at commit time; I just noticed it and thought I'd
mention it.

> + iteration_pool = svn_pool_create(pool);
> + for (sec_ndx = apr_hash_first(iteration_pool, cfg->sections);
> + sec_ndx != NULL;
> + sec_ndx = apr_hash_next(sec_ndx))
> + {
> + void *sec_ptr;
> + const void *sec_name;
> +
> + apr_hash_this(sec_ndx, &sec_name, NULL, &sec_ptr);
> + if (apr_fnmatch(sec_name, section, APR_FNM_PATHNAME | APR_FNM_CASE_BLIND) == APR_SUCCESS) {
> + sectionp = sec_ptr;
> + break;
> + }
> + ++count;
> + svn_pool_clear(iteration_pool);
> + }

Clear the iteration_pool at the top of the loop, not the bottom, so that
eventual loop-condition failure doesn't leave dangling storage.

Also, are you sure you want to pass iteration_pool to apr_hash_first(),
not pool? Think: we'll clear iteration_pool at the bottom of the first
iteration, then we'll refer into sec_ndx in order create a new sec_ndx.
That seems bad :-).

> + svn_pool_destroy(iteration_pool);
> +
> + return sectionp;
> +}

Finally, what is the 'count' variable for?

-Karl

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe_at_subversion.tigris.org
For additional commands, e-mail: dev-help_at_subversion.tigris.org
Received on 2008-05-28 18:11:28 CEST

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.