mirror of
https://github.com/git/git.git
synced 2026-06-24 08:48:31 +00:00
strbuf_attach: fix call sites to pass correct alloc
strbuf_attach(sb, buf, len, alloc) requires alloc > len (the buffer must have at least len+1 bytes to hold the NUL). Several call sites passed alloc == len, relying on strbuf_grow(sb, 0) inside strbuf_attach to reallocate. Fix these in mailinfo, am, refs/files-backend, fast-import, and trailer by passing len+1 when the buffer is a NUL-terminated string (or from strbuf_detach). Signed-off-by: Vaidas Pilkauskas <vaidas.pilkauskas@shopify.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
committed by
Junio C Hamano
parent
bc6a6cf5ee
commit
a4fddb01c5
@@ -1806,7 +1806,7 @@ static int commit_ref(struct ref_lock *lock)
|
||||
size_t len = strlen(path);
|
||||
struct strbuf sb_path = STRBUF_INIT;
|
||||
|
||||
strbuf_attach(&sb_path, path, len, len);
|
||||
strbuf_attach(&sb_path, path, len, len + 1);
|
||||
|
||||
/*
|
||||
* If this fails, commit_lock_file() will also fail
|
||||
|
||||
Reference in New Issue
Block a user