Skip to content

Commit def0697

Browse files
peffgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 28b3563 commit def0697

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

transport.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1369,11 +1369,11 @@ static int refs_from_alternate_cb(struct alternate_object_database *e,
13691369
while (other[len-1] == '/')
13701370
other[--len] = '\0';
13711371
if (len < 8 || memcmp(other + len - 8, "/objects", 8))
1372-
return 0;
1372+
goto out;
13731373
/* Is this a git repository with refs? */
13741374
memcpy(other + len - 8, "/refs", 6);
13751375
if (!is_directory(other))
1376-
return 0;
1376+
goto out;
13771377
other[len - 8] = '\0';
13781378
remote = remote_get(other);
13791379
transport = transport_get(remote, other);
@@ -1382,6 +1382,7 @@ static int refs_from_alternate_cb(struct alternate_object_database *e,
13821382
extra = extra->next)
13831383
cb->fn(extra, cb->data);
13841384
transport_disconnect(transport);
1385+
out:
13851386
free(other);
13861387
return 0;
13871388
}

0 commit comments

Comments
 (0)