@@ -326,6 +326,8 @@ static void check_connectivity(void)
326326
327327static int fsck_obj (struct object * obj )
328328{
329+ int err ;
330+
329331 if (obj -> flags & SEEN )
330332 return 0 ;
331333 obj -> flags |= SEEN ;
@@ -336,20 +338,13 @@ static int fsck_obj(struct object *obj)
336338
337339 if (fsck_walk (obj , NULL , & fsck_obj_options ))
338340 objerror (obj , "broken links" );
339- if (fsck_object (obj , NULL , 0 , & fsck_obj_options ))
340- return -1 ;
341-
342- if (obj -> type == OBJ_TREE ) {
343- struct tree * item = (struct tree * ) obj ;
344-
345- free_tree_buffer (item );
346- }
341+ err = fsck_object (obj , NULL , 0 , & fsck_obj_options );
342+ if (err )
343+ goto out ;
347344
348345 if (obj -> type == OBJ_COMMIT ) {
349346 struct commit * commit = (struct commit * ) obj ;
350347
351- free_commit_buffer (commit );
352-
353348 if (!commit -> parents && show_root )
354349 printf ("root %s\n" , describe_object (& commit -> object ));
355350 }
@@ -365,7 +360,12 @@ static int fsck_obj(struct object *obj)
365360 }
366361 }
367362
368- return 0 ;
363+ out :
364+ if (obj -> type == OBJ_TREE )
365+ free_tree_buffer ((struct tree * )obj );
366+ if (obj -> type == OBJ_COMMIT )
367+ free_commit_buffer ((struct commit * )obj );
368+ return err ;
369369}
370370
371371static int fsck_obj_buffer (const struct object_id * oid , enum object_type type ,
0 commit comments