diff mbox series

[v3,16/16] pull: trivial memory fix

Message ID 20201205195313.1557473-17-felipe.contreras@gmail.com (mailing list archive)
State Superseded
Headers show
Series [v3,01/16] doc: pull: explain what is a fast-forward | expand

Commit Message

Felipe Contreras Dec. 5, 2020, 7:53 p.m. UTC
The opt_ff variable is supposed to have an allocated string (strdup), we
can't just overwrite it with a const char *.

Functionally it doesn't matter, since after this point opt_ff is never
freed, only accessed, but still...

It's better to be consistent.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
 builtin/pull.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/builtin/pull.c b/builtin/pull.c
index 54c58618e9..0735c77f42 100644
--- a/builtin/pull.c
+++ b/builtin/pull.c
@@ -1057,7 +1057,8 @@  int cmd_pull(int argc, const char **argv, const char *prefix)
 
 		if (can_ff) {
 			/* we can fast-forward this without invoking rebase */
-			opt_ff = "--ff-only";
+			free(opt_ff);
+			opt_ff = xstrdup_or_null("--ff-only");
 			ret = run_merge();
 		} else {
 			ret = run_rebase(&curr_head, merge_heads.oid, &rebase_fork_point);