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

Re: [PATCH] adm_files.c:adm_subdir()

From: Karl Fogel <kfogel_at_galois.collab.net>
Date: 2000-09-11 18:29:17 CEST

Joe Orton <joe@light.plus.com> writes:
> Is this function safe? As I read it, it allocates a string in a pool,
> but expects it to last for the lifetime of the process.

Seems unsafe to me too, thanks for noticing. I needed a "guardian"
function right away for accessing the adm area, so no other part of
the code would ever be tempted to hardcode the "./SVN/" path, so
that's what this is. At least it's unsafe in exactly one place. :-)

I'll fix it.

> Could do something complex and not very efficient with
> apr_set/get_userdata, but maybe something simpler is okay for the time
> being:
>
> --- adm_files.c.orig Sat Sep 9 08:51:56 2000
> +++ adm_files.c Mon Sep 11 11:01:35 2000
> @@ -73,15 +73,10 @@
> /* No one outside this file should ever need to know this. In fact,
> no one outside adm_subdir() should ever need to know this. */
> #define SVN_WC__ADM_DIR_DEFAULT "SVN"
> -static svn_string_t *
> +static const char *
> adm_subdir (apr_pool_t *pool)
> {
> - static svn_string_t *adm_dir_str = NULL;
> -
> - if (! adm_dir_str)
> - adm_dir_str = svn_string_create (SVN_WC__ADM_DIR_DEFAULT, pool);
> -
> - return adm_dir_str;
> + return SVN_WC__ADM_DIR_DEFAULT;
> }
>
>
> @@ -106,7 +101,8 @@
> {
> int components_added = 0;
>
> - svn_path_add_component (path, adm_subdir (pool), SVN_PATH_LOCAL_STYLE, pool);
> + svn_path_add_component_nts (path, adm_subdir (pool), SVN_PATH_LOCAL_STYLE,
> + pool);
> components_added++;
>
> if (adm_file && (adm_file[0] != '\0'))
Received on Sat Oct 21 14:36:08 2006

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.