@matheusbsbs / matheus-bagliano / commits / 3b683b91cd
Fork 0

Fix some more memory leaks in http-push.c

Signed-off-by: Mike Hommey <mh@glandium.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Mike Hommey committed Dec 14, 2007 at 22:18 UTC 3b683b91cd78dec027105a2810079eb0b27ab2c0
1 file changed +11 -2
http-push.c
+11 -2
@@ -925,11 +925,14 @@ static int fetch_index(unsigned char *sha1)
925 hex);
926 }
927 } else {
928 + free(url);
929 return error("Unable to start request");
930 }
931
931 - if (has_pack_index(sha1))
932 + if (has_pack_index(sha1)) {
933 + free(url);
934 return 0;
935 + }
936
937 if (push_verbosely)
938 fprintf(stderr, "Getting index for pack %s\n", hex);
@@ -939,9 +942,11 @@ static int fetch_index(unsigned char *sha1)
942 filename = sha1_pack_index_name(sha1);
943 snprintf(tmpfile, sizeof(tmpfile), "%s.temp", filename);
944 indexfile = fopen(tmpfile, "a");
942 - if (!indexfile)
945 + if (!indexfile) {
946 + free(url);
947 return error("Unable to open local file %s for pack index",
948 tmpfile);
949 + }
950
951 slot = get_active_slot();
952 slot->results = &results;
@@ -1135,10 +1140,12 @@ int fetch_ref(char *ref, unsigned char *sha1)
1140 curl_easy_setopt(slot->curl, CURLOPT_URL, url);
1141 if (start_active_slot(slot)) {
1142 run_active_slot(slot);
1143 + free(url);
1144 if (results.curl_result != CURLE_OK)
1145 return error("Couldn't get %s for %s\n%s",
1146 url, ref, curl_errorstr);
1147 } else {
1148 + free(url);
1149 return error("Unable to start request");
1150 }
1151
@@ -2107,6 +2114,7 @@ static int remote_exists(const char *path)
2114
2115 if (start_active_slot(slot)) {
2116 run_active_slot(slot);
2117 + free(url);
2118 if (results.http_code == 404)
2119 return 0;
2120 else if (results.curl_result == CURLE_OK)
@@ -2114,6 +2122,7 @@ static int remote_exists(const char *path)
2122 else
2123 fprintf(stderr, "HEAD HTTP error %ld\n", results.http_code);
2124 } else {
2125 + free(url);
2126 fprintf(stderr, "Unable to start HEAD request\n");
2127 }
2128