Commit e1e90dcc by Patrick Steinhardt

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.
parent 83b5f161
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment