mirror of
https://git.proxmox.com/git/libgit2
synced 2025-08-10 00:12:15 +00:00
config: saner iterator errors
Really report an error in foreach if we fail to allocate the iterator, and don't fail if the config is emtpy.
This commit is contained in:
parent
82ae6fcdba
commit
84fec6f628
@ -340,8 +340,10 @@ int git_config_backend_foreach_match(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (backend->iterator_new(&iter, backend) < 0)
|
if ((result = backend->iterator_new(&iter, backend)) < 0) {
|
||||||
return 0;
|
iter = NULL;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
while(!(backend->next(&entry, iter) < 0)) {
|
while(!(backend->next(&entry, iter) < 0)) {
|
||||||
/* skip non-matching keys if regexp was provided */
|
/* skip non-matching keys if regexp was provided */
|
||||||
|
@ -261,9 +261,6 @@ static int config_iterator_new(
|
|||||||
diskfile_backend *b = (diskfile_backend *)backend;
|
diskfile_backend *b = (diskfile_backend *)backend;
|
||||||
git_config_file_iter *it = git__calloc(1, sizeof(git_config_file_iter));
|
git_config_file_iter *it = git__calloc(1, sizeof(git_config_file_iter));
|
||||||
|
|
||||||
if (!b->values || git_strmap_num_entries(b->values) < 1)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
GITERR_CHECK_ALLOC(it);
|
GITERR_CHECK_ALLOC(it);
|
||||||
|
|
||||||
it->parent.backend = backend;
|
it->parent.backend = backend;
|
||||||
|
Loading…
Reference in New Issue
Block a user