You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@subversion.apache.org by Josh Pieper <jj...@pobox.com> on 2004/07/05 15:50:48 UTC
Re: svn commit: r10143 - in trunk/subversion: libsvn_subr tests/libsvn_subr
Greg Hudson wrote:
> On Mon, 2004-07-05 at 09:06, jpieper@tigris.org wrote:
> > - while (path->len > 0 && path->data[path->len - 1] != '/')
> > + while (path->len > 0 && path->data[path->len] != '/')
> > --path->len;
> > +
> > + if (path->len == 0 && path->data[0] == '/')
> > + path->len++;
>
> The valid indices of path->data range from 0 to path->len - 1. Your new
> code starts accessing path->data[path->len] right off the bat, which is
> invalid, and then accesses path->data[0] at the end if path->len is 0,
> which is also invalid if path->len was 0 to start with.
I though svn_stringbuf_t maintained the invariant that
path->data[path->len] == '\0'?
-Josh
--
To be is to be related.
-- C.J. Keyser.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Re: svn commit: r10143 - in trunk/subversion: libsvn_subr
tests/libsvn_subr
Posted by Greg Hudson <gh...@MIT.EDU>.
On Mon, 2004-07-05 at 11:50, Josh Pieper wrote:
> > The valid indices of path->data range from 0 to path->len - 1. Your new
> > code starts accessing path->data[path->len] right off the bat, which is
> > invalid, and then accesses path->data[0] at the end if path->len is 0,
> > which is also invalid if path->len was 0 to start with.
>
> I though svn_stringbuf_t maintained the invariant that
> path->data[path->len] == '\0'?
Oh, of course you're right.
But the purpose of that invariant is to make str->data work as a C
string. Using it for other purposes is confusing (as I just
demonstrated by becoming confused), so I like Klaus's approach better.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org