mirror of
https://github.com/git-for-windows/git.git
synced 2026-06-26 14:40:57 -05:00
diffcore: widen struct diff_filespec.size to size_t
Continue the size_t evacuation. The struct field already receives its writes from a size_t-shaped source (xsize_t(st.st_size), strbuf.len, fill_textconv()'s return, odb_read_object_info_extended() via oi.sizep), so on Windows it was already truncating anything past 4 GiB silently on the strbuf and textconv paths and loudly through cast_size_t_to_ulong() on the odb path. Switch the field to size_t. In diff_populate_filespec(), point oi.sizep at the field directly and drop both cast_size_t_to_ulong() shims and the size_st bridge they fed. Downstream consumers that still read .size into unsigned long locals will now silently narrow on Windows where the field exceeds 4 GiB. Each of those is its own follow-up; the writer side is the prerequisite for ever putting a >4 GiB value in the field in the first place. Assisted-by: Opus 4.7 Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
This commit is contained in:
5
diff.c
5
diff.c
@@ -4595,9 +4595,8 @@ int diff_populate_filespec(struct repository *r,
|
||||
}
|
||||
}
|
||||
else {
|
||||
size_t size_st = 0;
|
||||
struct object_info info = {
|
||||
.sizep = &size_st
|
||||
.sizep = &s->size
|
||||
};
|
||||
|
||||
if (!(size_only || check_binary))
|
||||
@@ -4619,7 +4618,6 @@ int diff_populate_filespec(struct repository *r,
|
||||
die("unable to read %s", oid_to_hex(&s->oid));
|
||||
|
||||
object_read:
|
||||
s->size = cast_size_t_to_ulong(size_st);
|
||||
if (size_only || check_binary) {
|
||||
if (size_only)
|
||||
return 0;
|
||||
@@ -4634,7 +4632,6 @@ object_read:
|
||||
if (odb_read_object_info_extended(r->objects, &s->oid, &info,
|
||||
OBJECT_INFO_LOOKUP_REPLACE))
|
||||
die("unable to read %s", oid_to_hex(&s->oid));
|
||||
s->size = cast_size_t_to_ulong(size_st);
|
||||
}
|
||||
s->should_free = 1;
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ struct diff_filespec {
|
||||
char *path;
|
||||
void *data;
|
||||
void *cnt_data;
|
||||
unsigned long size;
|
||||
size_t size;
|
||||
int count; /* Reference count */
|
||||
int rename_used; /* Count of rename users */
|
||||
unsigned short mode; /* file mode */
|
||||
|
||||
Reference in New Issue
Block a user