builtin-fast-export.c: fix crash on tagged trees
If a tag object points to a tree (or another unhandled type), the commit- pointer is left uninitialized and later dereferenced. This patch adds a default case to the switch that issues a warning and skips the object. Signed-off-by: Erik Faye-Lund <kusmabite@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Erik Faye-Lund committed
Mar 23, 2009 at 12:53 UTC
426193c025eb76125a99b3fe143eea50e849f9ca
2 files changed
+6
-3
builtin-fast-export.c
+4
@@ -375,6 +375,10 @@ static void get_tags_and_duplicates(struct object_array *pending,
375
case OBJ_BLOB:
376
handle_object(tag->object.sha1);
377
continue;
378
+ default:
379
+ warning("Tag points to object of unexpected type %s, skipping.",
380
+ typename(tag->object.type));
381
+ continue;
382
}
383
break;
384
default:
t/t9301-fast-export.sh
+2
-3
@@ -269,9 +269,8 @@ test_expect_success 'set-up a few more tags for tag export tests' '
269
'
270
271
# NEEDSWORK: not just check return status, but validate the output
272
-# two tests commented out due to crash and thus unreliable return code
273
-test_expect_failure 'tree_tag' 'git fast-export tree_tag'
274
-test_expect_failure 'tree_tag-obj' 'git fast-export tree_tag-obj'
272
+test_expect_success 'tree_tag' 'git fast-export tree_tag'
273
+test_expect_success 'tree_tag-obj' 'git fast-export tree_tag-obj'
274
test_expect_failure 'tag-obj_tag' 'git fast-export tag-obj_tag'
275
test_expect_failure 'tag-obj_tag-obj' 'git fast-export tag-obj_tag-obj'
276