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
index 64542ac3dea48e3a92901319233aa3a1e0c4cb9a,ab0de7b9d3ef5002644b841825154af75dcde349..d18244ab546bae863e6ef81d58663dc5c27c49c0
@@@ -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)
  {
        /*