diff options
author | Edward Thomson <ethomson@edwardthomson.com> | 2020-05-23 10:15:51 +0100 |
---|---|---|
committer | Patrick Steinhardt <ps@pks.im> | 2020-06-01 14:12:17 +0200 |
commit | 0f35efeb5722f950218e3649d7814a6a91b1c351 (patch) | |
tree | e53af9e934365660d0bacfd4c24b40434dfd353f /src/attr_file.c | |
parent | abfdb8a6d252a4834df9234ad338c97f1a4f97f2 (diff) | |
download | libgit2-ethomson/poolinit.tar.gz |
git_pool_init: handle failure casesethomson/poolinit
Propagate failures caused by pool initialization errors.
Diffstat (limited to 'src/attr_file.c')
-rw-r--r-- | src/attr_file.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/attr_file.c b/src/attr_file.c index 82da5268f..3f69b5ffc 100644 --- a/src/attr_file.c +++ b/src/attr_file.c @@ -41,16 +41,21 @@ int git_attr_file__new( if (git_mutex_init(&attrs->lock) < 0) { git_error_set(GIT_ERROR_OS, "failed to initialize lock"); - git__free(attrs); - return -1; + goto on_error; } - git_pool_init(&attrs->pool, 1); + if (git_pool_init(&attrs->pool, 1) < 0) + goto on_error; + GIT_REFCOUNT_INC(attrs); attrs->entry = entry; attrs->source = source; *out = attrs; return 0; + +on_error: + git__free(attrs); + return -1; } int git_attr_file__clear_rules(git_attr_file *file, bool need_lock) |