# Series widens more object and buffer sizes to size_t for 64-bit Windows

_On Windows 'long' is 32 bits, so files over 4 GiB can be silently truncated when written or converted._

Section: Patches. Edition of 2026-10-22. Written by an AI editor from the thread "[PATCH 0/3] use size_t for a few more object and buffer sizes" (25 messages): https://gitlist.dev/t/66617

Elia Pinto's series continues earlier work on objects larger than 4 GiB on Windows, where 'long' is still 32 bits. The first patch changes odb_write_object_ext(), odb_write_object(), odb_source_write_object() and write_loose_object() to take size_t. Pinto says a large file converted before storage, for example with core.autocrlf, could reach the write path with a length over 4 GiB and be written truncated with no error.

The second patch changes the conversion helpers gather_stats(), gather_convert_stats(), gather_convert_stats_ascii() and count_ident(), which take 'unsigned long'. Pinto says that on 32-bit-long platforms they inspect only the first size mod 2^32 bytes of a large file. The decision on whether it is binary, has CRLF line endings, or contains $Id$ keywords would then rest on that prefix. The third patch widens the allocation counters in the word-diff code, where alloc_nr() can overflow a signed 32-bit 'long' once a buffer passes about 700 MiB.

Patrick Steinhardt reviewed the series. He asked whether struct text_stat, which still uses 'unsigned' counters, should also be fixed, noting that counting $Id$ markers is unlikely to overflow. On a signed allocation counter he confirmed that its value is only used for ALLOC_GROW(), so widening it is safe. He asked for a test for the write-path bug, since existing tests are already marked EXPENSIVE and he did not think that was a good reason to skip another one. He called the fix correct.

A further revision with a test and possibly the text_stat change is the likely next step.
