Skip to content

Commit

Permalink
Fix http-fetch
Browse files Browse the repository at this point in the history
With the latest changes in fetch.c, http-fetch crashed accessing
write_ref[i], where write_ref was NULL.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <junkio@cox.net>
  • Loading branch information
Johannes Schindelin authored and Junio C Hamano committed Jul 29, 2006
1 parent fff8fd5 commit 1b03dfe
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions fetch.c
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ void pull_targets_free(int targets, char **target, const char **write_ref)
{
while (targets--) {
free(target[targets]);
if (write_ref[targets])
if (write_ref && write_ref[targets])
free((char *) write_ref[targets]);
}
}
Expand All @@ -263,7 +263,7 @@ int pull(int targets, char **target, const char **write_ref,
track_object_refs = 0;

for (i = 0; i < targets; i++) {
if (!write_ref[i])
if (!write_ref || !write_ref[i])
continue;

lock[i] = lock_ref_sha1(write_ref[i], NULL, 0);
Expand Down Expand Up @@ -295,7 +295,7 @@ int pull(int targets, char **target, const char **write_ref,
msg = NULL;
}
for (i = 0; i < targets; i++) {
if (!write_ref[i])
if (!write_ref || !write_ref[i])
continue;
ret = write_ref_sha1(lock[i], &sha1[20 * i], msg ? msg : "fetch (unknown)");
lock[i] = NULL;
Expand Down

0 comments on commit 1b03dfe

Please sign in to comment.