Skip to content

Commit ce1adb1

Browse files
committed
Merge branch 'ds/sparse-updates-oob-access-fix'
The code to skip unmerged paths in the index when sparse checkout is in use would have made out-of-bound access of the in-core index when the last path was unmerged, which has been corrected. * ds/sparse-updates-oob-access-fix: unpack-trees: avoid array out-of-bounds error
2 parents 9e8ed17 + 0eeb3be commit ce1adb1

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

unpack-trees.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -562,11 +562,11 @@ static int warn_conflicted_path(struct index_state *istate,
562562

563563
add_rejected_path(o, WARNING_SPARSE_UNMERGED_FILE, conflicting_path);
564564

565-
/* Find out how many higher stage entries at same path */
566-
while (++count < istate->cache_nr &&
567-
!strcmp(conflicting_path,
568-
istate->cache[i+count]->name))
569-
/* do nothing */;
565+
/* Find out how many higher stage entries are at same path */
566+
while ((++count) + i < istate->cache_nr &&
567+
!strcmp(conflicting_path, istate->cache[count + i]->name))
568+
; /* do nothing */
569+
570570
return count;
571571
}
572572

0 commit comments

Comments
 (0)