Skip to content

Commit 05ac978

Browse files
René Scharfegitster
authored andcommitted
pickaxe: plug diff filespec leak with empty needle
Check first for the unlikely case of an empty needle string and only then populate the filespec, lest we leak it. Signed-off-by: Rene Scharfe <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 703f05a commit 05ac978

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

diffcore-pickaxe.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,10 +152,10 @@ static unsigned int contains(struct diff_filespec *one,
152152
unsigned int cnt;
153153
unsigned long sz;
154154
const char *data;
155-
if (diff_populate_filespec(one, 0))
156-
return 0;
157155
if (!len)
158156
return 0;
157+
if (diff_populate_filespec(one, 0))
158+
return 0;
159159

160160
sz = one->size;
161161
data = one->data;

0 commit comments

Comments
 (0)