Skip to content

Commit 70d26c6

Browse files
Thomas Rastgitster
Thomas Rast
authored andcommitted
read_revisions_from_stdin: make copies for handle_revision_arg
read_revisions_from_stdin() has passed pointers to its read buffer down to handle_revision_arg() since its inception way back in 42cabc3 (Teach rev-list an option to read revs from the standard input., 2006-09-05). Even back then, this was a bug: through add_pending_object, the argument was recorded in the object_array's 'name' field. Fix it by making a copy whenever read_revisions_from_stdin() passes an argument down the callchain. The other caller runs handle_revision_arg() on argv[], where it would be redundant to make a copy. Signed-off-by: Thomas Rast <trast@inf.ethz.ch> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 7e20105 commit 70d26c6

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

revision.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1275,7 +1275,8 @@ static void read_revisions_from_stdin(struct rev_info *revs,
12751275
}
12761276
die("options not supported in --stdin mode");
12771277
}
1278-
if (handle_revision_arg(sb.buf, revs, 0, REVARG_CANNOT_BE_FILENAME))
1278+
if (handle_revision_arg(xstrdup(sb.buf), revs, 0,
1279+
REVARG_CANNOT_BE_FILENAME))
12791280
die("bad revision '%s'", sb.buf);
12801281
}
12811282
if (seen_dashdash)

0 commit comments

Comments
 (0)