diff options
author | Patrick Steinhardt <ps@pks.im> | 2018-01-09 14:52:34 +0000 |
---|---|---|
committer | Patrick Steinhardt <ps@pks.im> | 2018-06-22 09:47:41 +0200 |
commit | e1e90dccb252dc92490ad620d98c581636df0adf (patch) | |
tree | 089a219064df980b9b061b55f90e2e289e0d860a | |
parent | 83b5f161facf117681df47cbeeb13b95dc3ea9c5 (diff) | |
download | libgit2-e1e90dccb252dc92490ad620d98c581636df0adf.tar.gz |
config_file: avoid free'ing OOM buffers
Buffers which ran out of memory will never have any memory attached to
them. As such, it is not necessary to call `git_buf_free` if the buffer
is out of memory.
-rw-r--r-- | src/config_file.c | 8 |
1 files changed, 2 insertions, 6 deletions
diff --git a/src/config_file.c b/src/config_file.c index 84f6dd153..ea72648aa 100644 --- a/src/config_file.c +++ b/src/config_file.c @@ -876,10 +876,8 @@ static char *escape_value(const char *ptr) ptr++; } - if (git_buf_oom(&buf)) { - git_buf_dispose(&buf); + if (git_buf_oom(&buf)) return NULL; - } return git_buf_detach(&buf); } @@ -1042,10 +1040,8 @@ static int read_on_variable( for (c = var_name; *c; c++) git_buf_putc(&buf, git__tolower(*c)); - if (git_buf_oom(&buf)) { - git_buf_free(&buf); + if (git_buf_oom(&buf)) return -1; - } entry = git__calloc(1, sizeof(git_config_entry)); GITERR_CHECK_ALLOC(entry); |