diff --git a/cache-tree.c b/cache-tree.c index 28b78f88ef..e452238ba7 100644 --- a/cache-tree.c +++ b/cache-tree.c @@ -440,6 +440,8 @@ static struct cache_tree *read_one(const char **buffer, unsigned long *size_p) { const char *buf = *buffer; unsigned long size = *size_p; + const char *cp; + char *ep; struct cache_tree *it; int i, subtree_nr; @@ -453,7 +455,14 @@ static struct cache_tree *read_one(const char **buffer, unsigned long *size_p) goto free_return; buf++; size--; it = cache_tree(); - if (sscanf(buf, "%d %d\n", &it->entry_count, &subtree_nr) != 2) + + cp = buf; + it->entry_count = strtol(cp, &ep, 10); + if (cp == ep) + goto free_return; + cp = ep; + subtree_nr = strtol(cp, &ep, 10); + if (cp == ep) goto free_return; while (size && *buf && *buf != '\n') { size--; diff --git a/fsck-objects.c b/fsck-objects.c index cc09143a92..98421aab30 100644 --- a/fsck-objects.c +++ b/fsck-objects.c @@ -446,6 +446,8 @@ static int fsck_cache_tree(struct cache_tree *it) if (0 <= it->entry_count) { struct object *obj = parse_object(it->sha1); + mark_reachable(obj, REACHABLE); + obj->used = 1; if (obj->type != tree_type) err |= objerror(obj, "non-tree in cache-tree"); }