Commit ff8d2eb1 by Patrick Steinhardt

blame_git: check return value of object lookup

The function `pass_whole_blame` performs an object lookup but does not
check if the lookup actually succeeds. Convert the function to return an
error code and check for it in the calling function.
parent dd0b1e8c
...@@ -478,14 +478,15 @@ cleanup: ...@@ -478,14 +478,15 @@ cleanup:
* The blobs of origin and porigin exactly match, so everything origin is * The blobs of origin and porigin exactly match, so everything origin is
* suspected for can be blamed on the parent. * suspected for can be blamed on the parent.
*/ */
static void pass_whole_blame(git_blame *blame, static int pass_whole_blame(git_blame *blame,
git_blame__origin *origin, git_blame__origin *porigin) git_blame__origin *origin, git_blame__origin *porigin)
{ {
git_blame__entry *e; git_blame__entry *e;
if (!porigin->blob) if (!porigin->blob &&
git_object_lookup((git_object**)&porigin->blob, blame->repository, git_object_lookup((git_object**)&porigin->blob, blame->repository,
git_blob_id(origin->blob), GIT_OBJ_BLOB); git_blob_id(origin->blob), GIT_OBJ_BLOB) < 0)
return -1;
for (e=blame->ent; e; e=e->next) { for (e=blame->ent; e; e=e->next) {
if (!same_suspect(e->suspect, origin)) if (!same_suspect(e->suspect, origin))
continue; continue;
...@@ -493,6 +494,8 @@ static void pass_whole_blame(git_blame *blame, ...@@ -493,6 +494,8 @@ static void pass_whole_blame(git_blame *blame,
origin_decref(e->suspect); origin_decref(e->suspect);
e->suspect = porigin; e->suspect = porigin;
} }
return 0;
} }
static int pass_blame(git_blame *blame, git_blame__origin *origin, uint32_t opt) static int pass_blame(git_blame *blame, git_blame__origin *origin, uint32_t opt)
...@@ -543,7 +546,8 @@ static int pass_blame(git_blame *blame, git_blame__origin *origin, uint32_t opt) ...@@ -543,7 +546,8 @@ static int pass_blame(git_blame *blame, git_blame__origin *origin, uint32_t opt)
} }
if (porigin->blob && origin->blob && if (porigin->blob && origin->blob &&
!git_oid_cmp(git_blob_id(porigin->blob), git_blob_id(origin->blob))) { !git_oid_cmp(git_blob_id(porigin->blob), git_blob_id(origin->blob))) {
pass_whole_blame(blame, origin, porigin); error = pass_whole_blame(blame, origin, porigin);
goto finish;
origin_decref(porigin); origin_decref(porigin);
goto finish; goto finish;
} }
......
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