Thread (1 message) 1 message, 1 author, 2016-06-15

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

From: Horst von Brand <hidden>
Date: 2016-06-15 22:42:15

Junio C Hamano [off-list ref] wrote:
Pavel Roskin [off-list ref] writes:
[...]
quoted
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?
quoted
-	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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help