]> granicus.if.org Git - git/commitdiff
read_revisions_from_stdin: make copies for handle_revision_arg
authorThomas Rast <trast@inf.ethz.ch>
Tue, 16 Apr 2013 09:57:45 +0000 (11:57 +0200)
committerJunio C Hamano <gitster@pobox.com>
Tue, 16 Apr 2013 18:17:48 +0000 (11:17 -0700)
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>
revision.c

index ae12e11fb74dcc51bfddd2acf94601b2bfba7811..a50df66c50ed4c9b8118ba511f0d67fc7ed7e5ab 100644 (file)
@@ -1275,7 +1275,8 @@ static void read_revisions_from_stdin(struct rev_info *revs,
                        }
                        die("options not supported in --stdin mode");
                }
-               if (handle_revision_arg(sb.buf, revs, 0, REVARG_CANNOT_BE_FILENAME))
+               if (handle_revision_arg(xstrdup(sb.buf), revs, 0,
+                                       REVARG_CANNOT_BE_FILENAME))
                        die("bad revision '%s'", sb.buf);
        }
        if (seen_dashdash)