Commit 97eb5ef0262bc0acf2ce66481105960b79e10ed7

Patrick Steinhardt 2017-06-07T10:05:54

buffer: rely on `GITERR_OOM` set by `git_buf_try_grow` The function `git_buf_try_grow` consistently calls `giterr_set_oom` whenever growing the buffer fails due to insufficient memory being available. So in fact, we do not have to do this ourselves when a call to any buffer-growing function has failed due to an OOM situation. But we still do so in two functions, which this patch cleans up.

diff --git a/src/pack.c b/src/pack.c
index 60b757e..d24c138 100644
--- a/src/pack.c
+++ b/src/pack.c
@@ -324,7 +324,6 @@ static int pack_index_open(struct git_pack_file *p)
 	git_buf_put(&idx_name, p->pack_name, name_len - strlen(".pack"));
 	git_buf_puts(&idx_name, ".idx");
 	if (git_buf_oom(&idx_name)) {
-		giterr_set_oom();
 		return -1;
 	}
 
diff --git a/src/transports/winhttp.c b/src/transports/winhttp.c
index e8e8480..fb504c9 100644
--- a/src/transports/winhttp.c
+++ b/src/transports/winhttp.c
@@ -429,7 +429,6 @@ static int winhttp_stream_connect(winhttp_stream *s)
 			git_buf_printf(&processed_url, ":%s", t->proxy_connection_data.port);
 
 		if (git_buf_oom(&processed_url)) {
-			giterr_set_oom();
 			error = -1;
 			goto on_error;
 		}