]> git.ipfire.org Git - thirdparty/git.git/commit - cache-tree.c
cache-tree: fix strbuf growth in prime_cache_tree_rec()
authorRené Scharfe <l.s.r@web.de>
Fri, 10 Feb 2023 20:20:30 +0000 (21:20 +0100)
committerJunio C Hamano <gitster@pobox.com>
Fri, 10 Feb 2023 20:24:12 +0000 (12:24 -0800)
commit93ea118bedf3f6d300520718250bf64d0e09a4ec
treed9edbeb8236f6f3b74b4f13873476f89d2442e09
parent844ede312b4e988881b6e27e352f469d8ab80b2a
cache-tree: fix strbuf growth in prime_cache_tree_rec()

Use size_t to store the original length of the strbuf tree_len, as
that's the correct type.

Don't double the allocated size of the strbuf when adding a subdirectory
name.  And the chance of the trailing slash fitting in the slack left by
strbuf_add() is very high, so stop pre-growing the strbuf at all.

Suggested-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
cache-tree.c