From 84fec6f628b8c82a70c0aff5dc6a47d1cdb6fbf0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn=20Nieto?= Date: Thu, 8 Aug 2013 13:14:35 +0200 Subject: [PATCH] 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. --- src/config.c | 6 ++++-- src/config_file.c | 3 --- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/config.c b/src/config.c index 2f800a896..6c055e0e6 100644 --- a/src/config.c +++ b/src/config.c @@ -340,8 +340,10 @@ int git_config_backend_foreach_match( } } - if (backend->iterator_new(&iter, backend) < 0) - return 0; + if ((result = backend->iterator_new(&iter, backend)) < 0) { + iter = NULL; + return -1; + } while(!(backend->next(&entry, iter) < 0)) { /* skip non-matching keys if regexp was provided */ diff --git a/src/config_file.c b/src/config_file.c index 849ef0f6f..6eb51ac25 100644 --- a/src/config_file.c +++ b/src/config_file.c @@ -261,9 +261,6 @@ static int config_iterator_new( diskfile_backend *b = (diskfile_backend *)backend; 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); it->parent.backend = backend;