Commit e1e90dccb252dc92490ad620d98c581636df0adf

Patrick Steinhardt 2018-01-09T14:52:34

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.

diff --git a/src/config_file.c b/src/config_file.c
index 84f6dd1..ea72648 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);