Commit 8a62bf11806d9118301999ff9c58d55057d06917

Patrick Steinhardt 2016-02-15T11:28:33

netops: fix memory leak when an error occurs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
diff --git a/src/netops.c b/src/netops.c
index 5e80755..c424198 100644
--- a/src/netops.c
+++ b/src/netops.c
@@ -261,6 +261,10 @@ int gitno_extract_url_parts(
 		*path = git__substrdup(_path, u.field_data[UF_PATH].len);
 		GITERR_CHECK_ALLOC(*path);
 	} else {
+		git__free(*port);
+		*port = NULL;
+		git__free(*host);
+		*host = NULL;
 		giterr_set(GITERR_NET, "invalid url, missing path");
 		return GIT_EINVALIDSPEC;
 	}