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

Re: svn commit: r1725957 - /subversion/trunk/subversion/svn/merge-cmd.c

From: Stefan Sperling <stsp_at_elego.de>
Date: Thu, 21 Jan 2016 17:25:26 +0100

On Thu, Jan 21, 2016 at 02:18:43PM -0000, kotkov_at_apache.org wrote:
> Author: kotkov
> Date: Thu Jan 21 14:18:43 2016
> New Revision: 1725957
>
> URL: http://svn.apache.org/viewvc?rev=1725957&view=rev
> Log:
> Allocate the baton for 'svn merge --accept' conflict callback in the pool,
> instead of using a pointer to stack.
>
> * subversion/svn/merge-cmd.c
> (svn_cl__merge): Allocate struct conflict_func_merge_cmd_baton in the
> pool. Otherwise, the ctx->conflict_baton2 pointer becomes dangling
> when the stack variable falls out of scope.
>
> Modified:
> subversion/trunk/subversion/svn/merge-cmd.c

Not objecting to this change, but I believe we do have a few
batons on the stack in several places and I don't think this
is a problem in general.

The stack memory will be available until the function returns,
which in this case is svn_cl__merge() i.e. the main entry point
to the subcommand.

The scope shouldn't matter since there's no garbage collection in C.

>
> Modified: subversion/trunk/subversion/svn/merge-cmd.c
> URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/svn/merge-cmd.c?rev=1725957&r1=1725956&r2=1725957&view=diff
> ==============================================================================
> --- subversion/trunk/subversion/svn/merge-cmd.c (original)
> +++ subversion/trunk/subversion/svn/merge-cmd.c Thu Jan 21 14:18:43 2016
> @@ -513,14 +513,14 @@ svn_cl__merge(apr_getopt_t *os,
> * See the docstring at conflict_func_merge_cmd() for details */
> if (opt_state->accept_which != svn_cl__accept_unspecified)
> {
> - struct conflict_func_merge_cmd_baton b;
> + struct conflict_func_merge_cmd_baton *b = apr_pcalloc(pool, sizeof(*b));
>
> - b.accept_which = opt_state->accept_which;
> - SVN_ERR(svn_dirent_get_absolute(&b.path_prefix, "", pool));
> - b.conflict_stats = conflict_stats;
> + b->accept_which = opt_state->accept_which;
> + SVN_ERR(svn_dirent_get_absolute(&b->path_prefix, "", pool));
> + b->conflict_stats = conflict_stats;
>
> ctx->conflict_func2 = conflict_func_merge_cmd;
> - ctx->conflict_baton2 = &b;
> + ctx->conflict_baton2 = b;
> }
>
> merge_err = run_merge(two_sources_specified,
>
>
Received on 2016-01-21 17:25:37 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.