Skip to content

Commit e1e90dc

Browse files
committed
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.
1 parent 83b5f16 commit e1e90dc

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

src/config_file.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -876,10 +876,8 @@ static char *escape_value(const char *ptr)
876876
ptr++;
877877
}
878878

879-
if (git_buf_oom(&buf)) {
880-
git_buf_dispose(&buf);
879+
if (git_buf_oom(&buf))
881880
return NULL;
882-
}
883881

884882
return git_buf_detach(&buf);
885883
}
@@ -1042,10 +1040,8 @@ static int read_on_variable(
10421040
for (c = var_name; *c; c++)
10431041
git_buf_putc(&buf, git__tolower(*c));
10441042

1045-
if (git_buf_oom(&buf)) {
1046-
git_buf_free(&buf);
1043+
if (git_buf_oom(&buf))
10471044
return -1;
1048-
}
10491045

10501046
entry = git__calloc(1, sizeof(git_config_entry));
10511047
GITERR_CHECK_ALLOC(entry);

0 commit comments

Comments
 (0)