Skip to content

Commit

Permalink
Fix some more memory leaks in http-push.c
Browse files Browse the repository at this point in the history
Signed-off-by: Mike Hommey <mh@glandium.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Mike Hommey authored and Junio C Hamano committed Dec 15, 2007
1 parent cb891a5 commit 3b683b9
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions http-push.c
Original file line number Diff line number Diff line change
Expand Up @@ -925,11 +925,14 @@ static int fetch_index(unsigned char *sha1)
hex);
}
} else {
free(url);
return error("Unable to start request");
}

if (has_pack_index(sha1))
if (has_pack_index(sha1)) {
free(url);
return 0;
}

if (push_verbosely)
fprintf(stderr, "Getting index for pack %s\n", hex);
Expand All @@ -939,9 +942,11 @@ static int fetch_index(unsigned char *sha1)
filename = sha1_pack_index_name(sha1);
snprintf(tmpfile, sizeof(tmpfile), "%s.temp", filename);
indexfile = fopen(tmpfile, "a");
if (!indexfile)
if (!indexfile) {
free(url);
return error("Unable to open local file %s for pack index",
tmpfile);
}

slot = get_active_slot();
slot->results = &results;
Expand Down Expand Up @@ -1135,10 +1140,12 @@ int fetch_ref(char *ref, unsigned char *sha1)
curl_easy_setopt(slot->curl, CURLOPT_URL, url);
if (start_active_slot(slot)) {
run_active_slot(slot);
free(url);
if (results.curl_result != CURLE_OK)
return error("Couldn't get %s for %s\n%s",
url, ref, curl_errorstr);
} else {
free(url);
return error("Unable to start request");
}

Expand Down Expand Up @@ -2107,13 +2114,15 @@ static int remote_exists(const char *path)

if (start_active_slot(slot)) {
run_active_slot(slot);
free(url);
if (results.http_code == 404)
return 0;
else if (results.curl_result == CURLE_OK)
return 1;
else
fprintf(stderr, "HEAD HTTP error %ld\n", results.http_code);
} else {
free(url);
fprintf(stderr, "Unable to start HEAD request\n");
}

Expand Down

0 comments on commit 3b683b9

Please sign in to comment.