Skip to content

Commit 2c0fa66

Browse files
committed
Merge branch 'ab/fsck-unexpected-type'
Regression fix. * ab/fsck-unexpected-type: object-file: free(*contents) only in read_loose_object() caller object-file: fix SEGV on free() regression in v2.34.0-rc2
2 parents 8996d68 + 16235e3 commit 2c0fa66

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

builtin/fsck.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -605,7 +605,7 @@ static int fsck_loose(const struct object_id *oid, const char *path, void *data)
605605
struct object *obj;
606606
enum object_type type = OBJ_NONE;
607607
unsigned long size;
608-
void *contents;
608+
void *contents = NULL;
609609
int eaten;
610610
struct object_info oi = OBJECT_INFO_INIT;
611611
struct object_id real_oid = *null_oid();
@@ -630,6 +630,7 @@ static int fsck_loose(const struct object_id *oid, const char *path, void *data)
630630
path);
631631
if (err < 0) {
632632
errors_found |= ERROR_OBJECT;
633+
free(contents);
633634
return 0; /* keep checking other objects */
634635
}
635636

object-file.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2557,10 +2557,9 @@ int read_loose_object(const char *path,
25572557
goto out;
25582558
}
25592559
if (check_object_signature(the_repository, expected_oid,
2560-
*contents, *size, oi->type_name->buf, real_oid)) {
2561-
free(*contents);
2560+
*contents, *size,
2561+
oi->type_name->buf, real_oid))
25622562
goto out;
2563-
}
25642563
}
25652564

25662565
ret = 0; /* everything checks out */

t/t1050-large.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,14 @@ test_expect_success setup '
1717
export GIT_ALLOC_LIMIT
1818
'
1919

20+
test_expect_success 'enter "large" codepath, with small core.bigFileThreshold' '
21+
test_when_finished "rm -rf repo" &&
22+
23+
git init --bare repo &&
24+
echo large | git -C repo hash-object -w --stdin &&
25+
git -C repo -c core.bigfilethreshold=4 fsck
26+
'
27+
2028
# add a large file with different settings
2129
while read expect config
2230
do

0 commit comments

Comments
 (0)