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

Re: [PATCH] Fix svn_log_changed_path_dup()

From: Daniel Berlin <dberlin_at_dberlin.org>
Date: 2006-05-30 17:12:34 CEST

Madan U Sreenivasan wrote:
> On Tue, 30 May 2006 20:00:45 +0530, C. Michael Pilato
> <cmpilato@collab.net> wrote:
>
>> Madan U Sreenivasan wrote:
>>
>>> === subversion/libsvn_subr/constructors.c
>>> ==================================================================
>>> --- subversion/libsvn_subr/constructors.c (revision 600)
>>> +++ subversion/libsvn_subr/constructors.c (local)
>>> @@ -60,12 +60,16 @@
>>> svn_log_changed_path_t *new_changed_path
>>> = apr_palloc(pool, sizeof(*new_changed_path));
>>>
>>> + /* Copy action */
>>> *new_changed_path = *changed_path;
>>>
>>> - if (new_changed_path->copyfrom_path)
>>> - new_changed_path->copyfrom_path =
>>> - apr_pstrdup(pool, new_changed_path->copyfrom_path);
>>> + /* Copy the copyfrom_path member variable */
>>> + new_changed_path->copyfrom_path =
>>> + apr_pstrdup(pool, changed_path->copyfrom_path);
>> apr_pstrdup() will SEGFAULT if you try to copy a NULL value.
>> changed_path->copyfrom_path must be NULL if
>> new_changed_path->copyfrom_path
>> was NULL due to the structure copy that precedes it (see below about
>> that).
>
> I paritally agree on the structure copy point. If a structure copy
> happens, all the changes suggested by my patch are unnecessary.

What do you mean "if"?

>
> But I'm not sure if all C compilers see *i = *p as a structure copy... I
> was under the impression that this behavior was guaranteed for all
> C++ compilers though.

It's guaranteed by the C standard as well.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Tue May 30 17:48:08 2006

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