transport: fix leaks in refs_from_alternate_cb
The function starts by creating a copy of the static buffer returned by real_path, but forgets to free it in the error code paths. We can solve this by jumping to the cleanup code that is already there. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
28b3563241
commit
def0697167
@ -1369,11 +1369,11 @@ static int refs_from_alternate_cb(struct alternate_object_database *e,
|
|||||||
while (other[len-1] == '/')
|
while (other[len-1] == '/')
|
||||||
other[--len] = '\0';
|
other[--len] = '\0';
|
||||||
if (len < 8 || memcmp(other + len - 8, "/objects", 8))
|
if (len < 8 || memcmp(other + len - 8, "/objects", 8))
|
||||||
return 0;
|
goto out;
|
||||||
/* Is this a git repository with refs? */
|
/* Is this a git repository with refs? */
|
||||||
memcpy(other + len - 8, "/refs", 6);
|
memcpy(other + len - 8, "/refs", 6);
|
||||||
if (!is_directory(other))
|
if (!is_directory(other))
|
||||||
return 0;
|
goto out;
|
||||||
other[len - 8] = '\0';
|
other[len - 8] = '\0';
|
||||||
remote = remote_get(other);
|
remote = remote_get(other);
|
||||||
transport = transport_get(remote, other);
|
transport = transport_get(remote, other);
|
||||||
@ -1382,6 +1382,7 @@ static int refs_from_alternate_cb(struct alternate_object_database *e,
|
|||||||
extra = extra->next)
|
extra = extra->next)
|
||||||
cb->fn(extra, cb->data);
|
cb->fn(extra, cb->data);
|
||||||
transport_disconnect(transport);
|
transport_disconnect(transport);
|
||||||
|
out:
|
||||||
free(other);
|
free(other);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user