]> git.ipfire.org Git - thirdparty/git.git/commit - strbuf.c
strbuf: release memory on read error in strbuf_read_once()
authorRené Scharfe <l.s.r@web.de>
Thu, 7 Dec 2017 20:51:26 +0000 (21:51 +0100)
committerJunio C Hamano <gitster@pobox.com>
Thu, 7 Dec 2017 21:19:23 +0000 (13:19 -0800)
commitc3ff8f6c145638afe996b51e91375fd94cd064d0
treebb9552a9296e9dbe1e81467e7e7511b574bdc4c1
parent9752ad0bb79f680bca48db7adc45338b298304b0
strbuf: release memory on read error in strbuf_read_once()

If other strbuf add functions cause the first allocation and
subsequently encounter an error then they release the memory, restoring
the pristine state of the strbuf.  That simplifies error handling for
callers.

Do the same in strbuf_read_once(), and do it also in case no bytes were
read -- which may or may not be an error as well, depending on the
caller.

Signed-off-by: Rene Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
strbuf.c