summaryrefslogtreecommitdiff
path: root/git-gui
diff options
context:
space:
mode:
authorKarthik Nayak <karthik.188@gmail.com>2025-10-01 14:17:29 +0200
committerJunio C Hamano <gitster@pobox.com>2025-10-01 13:12:24 -0700
commit351c6e719ae9c5b97506dde6bc287408b80e87e4 (patch)
tree23f1bf0ea4c1356fd8279e8e39bcdfff50f2ff5f /git-gui
parent821f583da6d30a84249f75f33501504d597bc16b (diff)
refs/ref-cache: fix SEGFAULT when seeking in empty directories
The 'cache_ref_iterator_seek()' function is used to seek the `ref_iterator` to the desired reference in the ref-cache mechanism. We use the seeking functionality to implement the '--start-after' flag in 'git-for-each-ref(1)'. When using the files-backend with packed-refs, it is possible that some of the refs directories are empty. For e.g. just after repacking, the 'refs/heads' directory would be empty. The ref-cache seek mechanism, doesn't take this into consideration when descending into a subdirectory, and makes an out of bounds access, causing SEGFAULT as we try to access entries within the directory. Fix this by breaking out of the loop when we enter an empty directory. Since we start with the base directory of 'refs/' which is never empty, it is okay to perform this check after the first iteration in the `do..while` clause. Add tests which simulate this behavior and also provide coverage over using the feature over packed-refs. Helped-by: Junio C Hamano <gitster@pobox.com> Signed-off-by: Karthik Nayak <karthik.188@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'git-gui')
0 files changed, 0 insertions, 0 deletions