Commit 240b6fed0075ae33e1ebc390c25d7503b2f18fb1

Carlos Martín Nieto 2016-02-05T15:19:24

Merge pull request #3578 from bubaflub/fix_small_memory_leak Free allocated pointer to curl stream on error

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
diff --git a/src/curl_stream.c b/src/curl_stream.c
index 798bd5a..9f8b202 100644
--- a/src/curl_stream.c
+++ b/src/curl_stream.c
@@ -207,11 +207,14 @@ int git_curl_stream_new(git_stream **out, const char *host, const char *port)
 	handle = curl_easy_init();
 	if (handle == NULL) {
 		giterr_set(GITERR_NET, "failed to create curl handle");
+		git__free(st);
 		return -1;
 	}
 
-	if ((error = git__strtol32(&iport, port, NULL, 10)) < 0)
+	if ((error = git__strtol32(&iport, port, NULL, 10)) < 0) {
+		git__free(st);
 		return error;
+	}
 
 	curl_easy_setopt(handle, CURLOPT_URL, host);
 	curl_easy_setopt(handle, CURLOPT_ERRORBUFFER, st->curl_error);