Skip to content

Commit b67588d

Browse files
committed
Merge branch 'rs/receive-pack-argv-leak-fix'
* rs/receive-pack-argv-leak-fix: receive-pack: plug minor memory leak in unpack()
2 parents 713ee7f + 64a7e92 commit b67588d

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

builtin/receive-pack.c

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1230,7 +1230,6 @@ static const char *pack_lockfile;
12301230
static const char *unpack(int err_fd, struct shallow_info *si)
12311231
{
12321232
struct pack_header hdr;
1233-
struct argv_array av = ARGV_ARRAY_INIT;
12341233
const char *hdr_err;
12351234
int status;
12361235
char hdr_arg[38];
@@ -1253,16 +1252,16 @@ static const char *unpack(int err_fd, struct shallow_info *si)
12531252

12541253
if (si->nr_ours || si->nr_theirs) {
12551254
alt_shallow_file = setup_temporary_shallow(si->shallow);
1256-
argv_array_pushl(&av, "--shallow-file", alt_shallow_file, NULL);
1255+
argv_array_push(&child.args, "--shallow-file");
1256+
argv_array_push(&child.args, alt_shallow_file);
12571257
}
12581258

12591259
if (ntohl(hdr.hdr_entries) < unpack_limit) {
1260-
argv_array_pushl(&av, "unpack-objects", hdr_arg, NULL);
1260+
argv_array_pushl(&child.args, "unpack-objects", hdr_arg, NULL);
12611261
if (quiet)
1262-
argv_array_push(&av, "-q");
1262+
argv_array_push(&child.args, "-q");
12631263
if (fsck_objects)
1264-
argv_array_push(&av, "--strict");
1265-
child.argv = av.argv;
1264+
argv_array_push(&child.args, "--strict");
12661265
child.no_stdout = 1;
12671266
child.err = err_fd;
12681267
child.git_cmd = 1;
@@ -1277,13 +1276,12 @@ static const char *unpack(int err_fd, struct shallow_info *si)
12771276
if (gethostname(keep_arg + s, sizeof(keep_arg) - s))
12781277
strcpy(keep_arg + s, "localhost");
12791278

1280-
argv_array_pushl(&av, "index-pack",
1279+
argv_array_pushl(&child.args, "index-pack",
12811280
"--stdin", hdr_arg, keep_arg, NULL);
12821281
if (fsck_objects)
1283-
argv_array_push(&av, "--strict");
1282+
argv_array_push(&child.args, "--strict");
12841283
if (fix_thin)
1285-
argv_array_push(&av, "--fix-thin");
1286-
child.argv = av.argv;
1284+
argv_array_push(&child.args, "--fix-thin");
12871285
child.out = -1;
12881286
child.err = err_fd;
12891287
child.git_cmd = 1;

0 commit comments

Comments
 (0)