Commit 2c90145a by Ben Straub

Fix potential segfault in revparse.

parent 68f527c4
...@@ -550,6 +550,11 @@ static int oid_for_tree_path(git_oid *out, git_tree *tree, git_repository *repo, ...@@ -550,6 +550,11 @@ static int oid_for_tree_path(git_oid *out, git_tree *tree, git_repository *repo,
} }
} }
if (!entry) {
giterr_set(GITERR_INVALID, "Invalid tree path '%s'", path);
return GIT_ERROR;
}
git_oid_cpy(out, git_tree_entry_id(entry)); git_oid_cpy(out, git_tree_entry_id(entry));
git__free(alloc); git__free(alloc);
return 0; return 0;
......
...@@ -163,6 +163,7 @@ void test_refs_revparse__colon(void) ...@@ -163,6 +163,7 @@ void test_refs_revparse__colon(void)
cl_git_fail(git_revparse_single(&g_obj, g_repo, ":/")); cl_git_fail(git_revparse_single(&g_obj, g_repo, ":/"));
cl_git_fail(git_revparse_single(&g_obj, g_repo, ":/not found in any commit")); cl_git_fail(git_revparse_single(&g_obj, g_repo, ":/not found in any commit"));
cl_git_fail(git_revparse_single(&g_obj, g_repo, ":2:README")); cl_git_fail(git_revparse_single(&g_obj, g_repo, ":2:README"));
cl_git_fail(git_revparse_single(&g_obj, g_repo, "master:"));
test_object("subtrees:ab/4.txt", "d6c93164c249c8000205dd4ec5cbca1b516d487f"); test_object("subtrees:ab/4.txt", "d6c93164c249c8000205dd4ec5cbca1b516d487f");
test_object("subtrees:ab/de/fgh/1.txt", "1f67fc4386b2d171e0d21be1c447e12660561f9b"); test_object("subtrees:ab/de/fgh/1.txt", "1f67fc4386b2d171e0d21be1c447e12660561f9b");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment