From: Junio C Hamano Date: Mon, 16 Nov 2026 15:24:35 GMT Subject: Re: [PATCH v2] http-backend: drop strbuf pre-sizing from get_info_packs() Message-ID: In-Reply-To: Patrick Steinhardt writes: >> This pre-sizing dates back to 2f4038ab33 (Git-aware CGI to provide dumb >> HTTP transport, 2009-10-30): `53` assumes the length of a SHA-1 >> "P pack-.pack\n" line (under-counting the 77-byte lines in SHA-256 >> repositories), and `cnt * 53 + 2` uses unchecked arithmetic. >> ... > Yeah, that's a much more convincing message. The other angle that this > is missing a bit is that giving a size hint ensures that we allocate > exactly as many bytes as we need. But that shouldn't matter in the > general case, and if you have to allocate gigabytes of memory to store > the list of packfiles... well, then you really have bigger problems to > worry about. Yeah, miscounting the preallocation is not a bug and just doing pointless work. I agree with you that for the purpose of sizing strbuf, you have a larger issue if you have to worry about overflowing arithmetic. > So I think this version is good enough, thanks! Thanks.