mirror of
https://github.com/libgit2/libgit2.git
synced 2026-06-22 06:26:26 +00:00
fix(refdb): check loose ref allocation failures
The loose ref lookup helper was exposed by7f35dc581and then used byb17ecb23edirectly for pseudoref lookup. While investigating the pseudoref owner regression, I found that the helper also returns success with a NULL output reference when `git_reference__alloc()` or `git_reference__alloc_symbolic()` failed. This fixes it by reporting allocation failures inside `git_reference__lookup_loose`.
This commit is contained in:
@@ -524,14 +524,20 @@ int git_reference__lookup_loose(
|
||||
|
||||
if (!(target = loose_parse_symbolic(&buf)))
|
||||
error = -1;
|
||||
else if (out != NULL)
|
||||
else if (out != NULL) {
|
||||
*out = git_reference__alloc_symbolic(ref_name, target);
|
||||
if (*out == NULL)
|
||||
error = -1;
|
||||
}
|
||||
} else {
|
||||
git_oid oid;
|
||||
|
||||
if (!(error = loose_parse_oid(&oid, ref_name, &buf, oid_type)) &&
|
||||
out != NULL)
|
||||
out != NULL) {
|
||||
*out = git_reference__alloc(ref_name, &oid, NULL);
|
||||
if (*out == NULL)
|
||||
error = -1;
|
||||
}
|
||||
}
|
||||
|
||||
git_str_dispose(&buf);
|
||||
|
||||
Reference in New Issue
Block a user