diff options
author | Karthik Nayak <karthik.188@gmail.com> | 2025-07-28 22:20:46 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2025-07-28 14:16:36 -0700 |
commit | 65855751d190d66d15bc2c7e17e93fe00d04c539 (patch) | |
tree | 37625384bb6ea900635b07c1f582496885dc6194 /commit-slab.h | |
parent | 9201261a70b5d325b344036de15901a4064d66c0 (diff) |
ref-cache: use 'size_t' instead of int for length
The commit 090eb5336c (refs: selectively set prefix in the seek
functions, 2025-07-15) modified the ref-cache iterator to support
seeking to a specified marker without setting the prefix.
The commit adds and uses an integer 'len' to capture the length of the
seek marker to compare with the entries of a given directory. Since the
type of the variable is 'int', this is met with a typecast of converting
a `strlen` to 'int' so it can be assigned to the 'len' variable.
This is whole operation is a bit wrong:
1. Since the 'len' variable is eventually used in a 'strncmp', it should
have been of type 'size_t'.
2. This also truncates the value provided from 'strlen' to an int, which
could cause a large refname to produce a negative number.
Let's do the correct thing here and simply use 'size_t' for `len`.
Signed-off-by: Karthik Nayak <karthik.188@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'commit-slab.h')
0 files changed, 0 insertions, 0 deletions