Merge branch 'ds/find-unique-abbrev-optim'
While finding unique object name abbreviation, the code may accidentally have read beyond the end of the array of object names in a pack. * ds/find-unique-abbrev-optim: sha1_name: fix uninitialized memory errors
This commit is contained in:
commit
7519a60ffa
@ -542,19 +542,19 @@ static void find_abbrev_len_for_pack(struct packed_git *p,
|
|||||||
/*
|
/*
|
||||||
* first is now the position in the packfile where we would insert
|
* first is now the position in the packfile where we would insert
|
||||||
* mad->hash if it does not exist (or the position of mad->hash if
|
* mad->hash if it does not exist (or the position of mad->hash if
|
||||||
* it does exist). Hence, we consider a maximum of three objects
|
* it does exist). Hence, we consider a maximum of two objects
|
||||||
* nearby for the abbreviation length.
|
* nearby for the abbreviation length.
|
||||||
*/
|
*/
|
||||||
mad->init_len = 0;
|
mad->init_len = 0;
|
||||||
if (!match) {
|
if (!match) {
|
||||||
nth_packed_object_oid(&oid, p, first);
|
if (nth_packed_object_oid(&oid, p, first))
|
||||||
extend_abbrev_len(&oid, mad);
|
extend_abbrev_len(&oid, mad);
|
||||||
} else if (first < num - 1) {
|
} else if (first < num - 1) {
|
||||||
nth_packed_object_oid(&oid, p, first + 1);
|
if (nth_packed_object_oid(&oid, p, first + 1))
|
||||||
extend_abbrev_len(&oid, mad);
|
extend_abbrev_len(&oid, mad);
|
||||||
}
|
}
|
||||||
if (first > 0) {
|
if (first > 0) {
|
||||||
nth_packed_object_oid(&oid, p, first - 1);
|
if (nth_packed_object_oid(&oid, p, first - 1))
|
||||||
extend_abbrev_len(&oid, mad);
|
extend_abbrev_len(&oid, mad);
|
||||||
}
|
}
|
||||||
mad->init_len = mad->cur_len;
|
mad->init_len = mad->cur_len;
|
||||||
|
Loading…
Reference in New Issue
Block a user