Merge branch 'rs/fsck-obj-leakfix' into maint
authorJunio C Hamano <gitster@pobox.com>
Sun, 10 Sep 2017 08:02:52 +0000 (17:02 +0900)
committerJunio C Hamano <gitster@pobox.com>
Sun, 10 Sep 2017 08:02:53 +0000 (17:02 +0900)
Memory leak in an error codepath has been plugged.

* rs/fsck-obj-leakfix:
  fsck: free buffers on error in fsck_obj()

1  2 
builtin/fsck.c

diff --cc builtin/fsck.c
@@@ -365,10 -369,15 +360,15 @@@ static int fsck_obj(struct object *obj
                }
        }
  
-       return 0;
+ out:
+       if (obj->type == OBJ_TREE)
+               free_tree_buffer((struct tree *)obj);
+       if (obj->type == OBJ_COMMIT)
+               free_commit_buffer((struct commit *)obj);
+       return err;
  }
  
 -static int fsck_obj_buffer(const unsigned char *sha1, enum object_type type,
 +static int fsck_obj_buffer(const struct object_id *oid, enum object_type type,
                           unsigned long size, void *buffer, int *eaten)
  {
        /*