Re: [PATCH 1/2] read_and_strip_branch: fix typo'd address-of operator

2015-01-28 Thread Junio C Hamano
Jeff King writes: > This is not the first time I've seen this chomp/trim distinction come > up. However, the thing that has prevented me from writing strbuf_chomp > is that the trim is almost always a more reasonable choice. > ... > End mini-rant. :) Thanks. -- To unsubscribe from this list: sen

Re: [PATCH 1/2] read_and_strip_branch: fix typo'd address-of operator

2015-01-28 Thread Jeff King
On Wed, Jan 28, 2015 at 12:42:26PM -0800, Junio C Hamano wrote: > > This is the most minimal fix, but I kind of wonder if it should just be > > using strbuf_rtrim (or even strbuf_trim) in the first place. > > Yeah. Or strbuf_chomp(), which does not exist ;-) This is not the first time I've seen

[PATCH 1/2] read_and_strip_branch: fix typo'd address-of operator

2015-01-28 Thread Jeff King
When we are chomping newlines from the end of a strbuf, we must check "sb.len != 0" before accessing "sb.buf[sb.len - 1]". However, this code mistakenly checks "&sb.len", which is always true (it is a part of an auto struct, so the address is always non-zero). This could lead to us accessing memory

Re: [PATCH 1/2] read_and_strip_branch: fix typo'd address-of operator

2015-01-28 Thread Junio C Hamano
Jeff King writes: > When we are chomping newlines from the end of a strbuf, we > must check "sb.len != 0" before accessing "sb.buf[sb.len - 1]". > However, this code mistakenly checks "&sb.len", which is > always true (it is a part of an auto struct, so the address > is always non-zero). This cou