Re: [PATCH] ls-files: don't try to prune an empty index
- Date: Sun, 16 Jul 2017 13:06:45 +0200
- From: René Scharfe <l.s.r@xxxxxx>
- Subject: Re: [PATCH] ls-files: don't try to prune an empty index
Am 16.07.2017 um 12:41 schrieb Jeff King:
On Sat, Jul 15, 2017 at 10:11:20PM +0200, René Scharfe wrote:
Exit early when asked to prune an index that contains no
entries to begin with. This avoids pointer arithmetic on
istate->cache, which is possibly NULL in that case.
Found with Clang's UBSan.
Makes sense. We could use MOVE_ARRAY() here, but this is a sensible
short-circuit to the whole function.
Looks like a good solution.
diff --git a/builtin/ls-files.c b/builtin/ls-files.c
index b8514a0029..adf572da68 100644
@@ -362,7 +362,7 @@ static void prune_index(struct index_state *istate,
unsigned int first, last;
- if (!prefix)
+ if (!prefix || !istate->cache_nr)
pos = index_name_pos(istate, prefix, prefixlen);
if (pos < 0)
"git am" complained that this does not apply to its blobs. Did you
I didn't, but perhaps I messed up the order of patches? MOVE_ARRAY
patch 2 touches the same file, but I wouldn't expect the two changes to
conflict. So not sure what's going on.