Commit e1ce5249e52e9c5271727d7e2ef5bba4c45277b9

Carlos Martín Nieto 2013-11-18T21:40:19

netops: fix leak

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
diff --git a/src/netops.c b/src/netops.c
index 15ed0fc..ad27d84 100644
--- a/src/netops.c
+++ b/src/netops.c
@@ -632,10 +632,13 @@ int gitno_connection_data_from_url(
 		size_t suffixlen = service_suffix ? strlen(service_suffix) : 0;
 
 		if (suffixlen &&
-			 !memcmp(path + pathlen - suffixlen, service_suffix, suffixlen))
+		    !memcmp(path + pathlen - suffixlen, service_suffix, suffixlen)) {
+			git__free(data->path);
 			data->path = git__strndup(path, pathlen - suffixlen);
-		else
+		} else {
+			git__free(data->path);
 			data->path = git__strdup(path);
+		}
 
 		/* Check for errors in the resulting data */
 		if (original_host && url[0] != '/' && strcmp(original_host, data->host)) {