Re: [PATCH] off-by-one bugs found by valgrind

From: Horst von Brand <vonbrand@inf.utfsm.cl>
Date: 2005-12-22 11:27:40
Junio C Hamano <junkio@cox.net> wrote:
> Pavel Roskin <proski@gnu.org> writes:

[...]

> > quote_c_style_counted() in quote.c uses a dangerous construct, when a
> > variable is incremented once and used twice in the same expression.
> 
> Sorry, I do not follow you.  Isn't && a sequence point?
> 
> > -	for (sp = name; (ch = *sp++) && (sp - name) <= namelen; ) {
> > -
> > +	for (sp = name; sp < name + namelen; sp++) {

Yes, it is, so it doesn't fix any bugs; but Pavel's version is definitely
more readable.
-- 
Dr. Horst H. von Brand                   User #22616 counter.li.org
Departamento de Informatica                     Fono: +56 32 654431
Universidad Tecnica Federico Santa Maria              +56 32 654239
Casilla 110-V, Valparaiso, Chile                Fax:  +56 32 797513
-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Received on Fri Dec 23 00:59:49 2005

This archive was generated by hypermail 2.1.8 : 2005-12-23 01:00:05 EST