"Bert Huijben" <[email protected]> writes: >> -----Original Message----- >> From: [email protected] [mailto:[email protected]] >> Sent: donderdag 8 maart 2012 5:01 >> To: [email protected] >> Subject: svn commit: r1298264 - in /subversion/branches/1.7.x: ./ STATUS >> subversion/libsvn_wc/props.c >> >> Author: svn-role >> Date: Thu Mar 8 04:01:23 2012 >> New Revision: 1298264 >> > >> Modified: subversion/branches/1.7.x/subversion/libsvn_wc/props.c >> URL: >> http://svn.apache.org/viewvc/subversion/branches/1.7.x/subversion/libsvn_wc >> /props.c?rev=1298264&r1=1298263&r2=1298264&view=diff >> ============================================================= >> ================= >> --- subversion/branches/1.7.x/subversion/libsvn_wc/props.c (original) >> +++ subversion/branches/1.7.x/subversion/libsvn_wc/props.c Thu Mar 8 >> 04:01:23 2012 >> @@ -2537,7 +2537,8 @@ svn_wc_canonicalize_svn_prop(const svn_s >> || strcmp(propname, SVN_PROP_EXTERNALS) == 0) >> { >> /* Make sure that the last line ends in a newline */ >> - if (propval->data[propval->len - 1] != '\n') >> + if (propval->len == 0 >> + || propval->data[propval->len - 1] != '\n') >> { >> new_value = svn_stringbuf_create_from_string(propval, pool); >> svn_stringbuf_appendbyte(new_value, '\n'); > > Looking at this patch again at a better hour: > > Why do we add a '\n' to a 0-byte property value. > > I think it should be 'propval->len > 0 && ...'
Perhaps. The original code would either leave '' as '' or change it to '\n' depending on the value of data[-1]. I suppose it is possible that data[-1] is outside valid memory and the original code might SEGV but usually date[-1] is in valid memory, it's just not part of the string, and so the result is sort of random. The client library seems to be happy with either a '' or '\n' result. If we assume that the most common case is that data[-1] != '\n' then the most common case would be to convert '' to '\n' and the new code preserves the most common behaviour. -- uberSVN: Apache Subversion Made Easy http://www.uberSVN.com

