OSDN Git Service

cat-file: fix memory leak
authorJohannes Schindelin <johannes.schindelin@gmx.de>
Thu, 4 May 2017 13:56:17 +0000 (15:56 +0200)
committerJunio C Hamano <gitster@pobox.com>
Mon, 8 May 2017 03:18:19 +0000 (12:18 +0900)
Discovered by Coverity.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/cat-file.c

index 1890d7a..9af863e 100644 (file)
@@ -165,6 +165,7 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name,
                die("git cat-file %s: bad file", obj_name);
 
        write_or_die(1, buf, size);
+       free(buf);
        return 0;
 }