Code

pickaxe: plug diff filespec leak with empty needle
authorRené Scharfe <rene.scharfe@lsrfire.ath.cx>
Thu, 6 Oct 2011 16:03:35 +0000 (18:03 +0200)
committerJunio C Hamano <gitster@pobox.com>
Fri, 7 Oct 2011 22:46:12 +0000 (15:46 -0700)
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>
diffcore-pickaxe.c

index c3760cfefd5dd123481b869eac3081b6e7d93201..0835a3be8d7b54e6654def5e7793cc0a38eed647 100644 (file)
@@ -152,10 +152,10 @@ static unsigned int contains(struct diff_filespec *one,
        unsigned int cnt;
        unsigned long sz;
        const char *data;
-       if (diff_populate_filespec(one, 0))
-               return 0;
        if (!len)
                return 0;
+       if (diff_populate_filespec(one, 0))
+               return 0;
 
        sz = one->size;
        data = one->data;