Re: [PATCH v8 1/4] sha1_file.c: support reading from a loose object of unknown type
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Apr 17, 2015, 19:23 UTC
- Message-ID
- <xmqqlhhqpnj5.fsf@gitster.dls.corp.google.com>
- In-Reply-To
- <553154C8.5090001@gmail.com>
karthik nayak <karthik.188@gmail.com> writes:
> + type = type_from_string_gently(buf, len, 1);
> + if (oi->typename) {
> + strbuf_add(oi->typename, buf, len);
> + strbuf_addch(oi->typename, '\0');add() has setlen() at the end so you do not have to NUL terminate it yourself. Doing addch() is actively wrong, as oi->typename->len now counts the terminating NUL as part of the string, no?