Skip to content

Commit 0227130

Browse files
dschogitster
authored andcommitted
attr: adjust a mismatched data type
On platforms where `size_t` does not have the same width as `unsigned long`, passing a pointer to the former when a pointer to the latter is expected can lead to problems. Windows and 32-bit Linux are among the affected platforms. In this instance, we want to store the size of the blob that was read in that variable. However, `read_blob_data_from_index()` passes that pointer to `read_object_file()` which expects an `unsigned long *`. Which means that on affected platforms, the variable is not fully populated and part of its value is left uninitialized. (On Big-Endian platforms, this problem would be even worse.) The consequence is that depending on the uninitialized memory's contents, we may erroneously reject perfectly fine attributes. Let's address this by passing a pointer to a variable of the expected data type. Signed-off-by: Johannes Schindelin <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent b7b37a3 commit 0227130

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

attr.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -745,7 +745,7 @@ static struct attr_stack *read_attr_from_index(const struct index_state *istate,
745745
struct attr_stack *res;
746746
char *buf, *sp;
747747
int lineno = 0;
748-
size_t size;
748+
unsigned long size;
749749

750750
if (!istate)
751751
return NULL;

0 commit comments

Comments
 (0)