OSDN Git Service

Merge branch 'rs/fsck-obj-leakfix'
authorJunio C Hamano <gitster@pobox.com>
Tue, 22 Aug 2017 17:29:13 +0000 (10:29 -0700)
committerJunio C Hamano <gitster@pobox.com>
Tue, 22 Aug 2017 17:29:14 +0000 (10:29 -0700)
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)
  {
        /*