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 <rene.scharfe@lsrfire.ath.cx> Signed-off-by: Junio C Hamano <gitster@pobox.com>

René Scharfe committed Oct 6, 2011 at 18:03 UTC 05ac978495e84fe03d91ab591524b7ea138900ed
1 file changed +2 -2
diffcore-pickaxe.c
+2 -2
@@ -152,10 +152,10 @@ static unsigned int contains(struct diff_filespec *one,
152 unsigned int cnt;
153 unsigned long sz;
154 const char *data;
155 - if (diff_populate_filespec(one, 0))
156 - return 0;
155 if (!len)
156 return 0;
157 + if (diff_populate_filespec(one, 0))
158 + return 0;
159
160 sz = one->size;
161 data = one->data;