Re: [PATCH v2 1/2] strbuf: make sure buffer is zero-terminated
- From
Jeff King <peff@peff.net>
- Date
- Apr 10, 2011, 20:57 UTC
- Message-ID
- <20110410205711.GA2069@sigill.intra.peff.net>
- In-Reply-To
- <1302468858-7376-1-git-send-email-kusmabite@gmail.com>
On Sun, Apr 10, 2011 at 10:54:17PM +0200, Erik Faye-Lund wrote:
> strbuf_init does not zero-terminate the initial buffer when hint is > non-zero. Fix this so strbuf_attach does not return garbage.
s/attach/detach/ I think. It is more than just detach, though; the NUL-termination is supposed to be an invariant of strbuf, so any code just looking at "sb.buf" would be broken. So your code looks fine, but you may want to mention that in the commit message.
-Peff