Ævar Arnfjörð Bjarmason <avarab@xxxxxxxxx> writes: > diff --git a/builtin/fsck.c b/builtin/fsck.c > index 260210bf8a1..30a516da29e 100644 > --- a/builtin/fsck.c > +++ b/builtin/fsck.c > @@ -615,12 +616,18 @@ static int fsck_loose(const struct object_id *oid, const char *path, void *data) > oi.sizep = &size; > oi.typep = &type; > > - if (read_loose_object(path, oid, &contents, &oi) < 0) > - err = error(_("%s: object corrupt or missing: %s"), > - oid_to_hex(oid), path); > + if (read_loose_object(path, oid, &real_oid, &contents, &oi) < 0) { > + if (contents && !oideq(&real_oid, oid)) > + err = error(_("%s: hash-path mismatch, found at: %s"), > + oid_to_hex(&real_oid), path); > + else > + err = error(_("%s: object corrupt or missing: %s"), > + oid_to_hex(oid), path); > + } > if (type != OBJ_NONE && type < 0) > err = error(_("%s: object is of unknown type '%s': %s"), > - oid_to_hex(oid), cb_data->obj_type.buf, path); > + oid_to_hex(&real_oid), cb_data->obj_type.buf, > + path); > if (err < 0) { > errors_found |= ERROR_OBJECT; > return 0; /* keep checking other objects */ When we say "hash-path mismatch", we would have non-null contents, presumably obtained from read_loose_object(). err is made negative when we give that messge, and we come here to return. Did we forget to free "contents" in that case?