@matheusbsbs / matheus-bagliano / commits / b96524f83a
Fork 0

builtin-checkout.c: check error return from read_cache()

Signed-off-by: Junio C Hamano <gitster@pobox.com>

Junio C Hamano committed Dec 5, 2008 at 17:54 UTC b96524f83aa6ba7bd08fb59bb0aa07453a984a8d
1 file changed +5 -2
builtin-checkout.c
+5 -2
@@ -228,7 +228,8 @@ static int checkout_paths(struct tree *source_tree, const char **pathspec,
228 struct lock_file *lock_file = xcalloc(1, sizeof(struct lock_file));
229
230 newfd = hold_locked_index(lock_file, 1);
231 - read_cache();
231 + if (read_cache() < 0)
232 + return error("corrupt index file");
233
234 if (source_tree)
235 read_tree_some(source_tree, pathspec);
@@ -371,7 +372,9 @@ static int merge_working_tree(struct checkout_opts *opts,
372 int ret;
373 struct lock_file *lock_file = xcalloc(1, sizeof(struct lock_file));
374 int newfd = hold_locked_index(lock_file, 1);
374 - read_cache();
375 +
376 + if (read_cache() < 0)
377 + return error("corrupt index file");
378
379 if (opts->force) {
380 ret = reset_tree(new->commit->tree, opts, 1);