# [PATCH] git-blame: prevent argument parsing segfault

2 messages from 2007-02-16 to 2007-02-16. Participants: Tommi Kyntola, Junio C Hamano.
Thread: https://gitlist.dev/t/6841

## Tommi Kyntola, 2007-02-16 07:38

Subject: [PATCH] git-blame: prevent argument parsing segfault
Message-ID: <45D55F6D.5090900@ray.fi>
URL: https://gitlist.dev/e/45D55F6D.5090900%40ray.fi

```

Description:
k@samael /localhome/k/git.git/git/gitweb % git-blame --incremental
zsh: segmentation fault  git blame --incremental

The 3rd branch in builtin-blame.c should also check for lacking
arguments. Running that in top dir avoids the problem because
the 'prefix' is NULL. The --incremental is no to blame here,
it only triggers the segfault and even without that flag it goes
checking argv too far.

I didn't check the pu branch, and I'm sorry if this is a dupe.

cheers,
Tommi "Kynde" Kyntola

diff --git a/builtin-blame.c b/builtin-blame.c
index 7a5665f..6d51b1f 100644
--- a/builtin-blame.c
+++ b/builtin-blame.c
@@ -2211,6 +2211,8 @@ int cmd_blame(int argc, const char **argv, const char *prefix)
                 }
                 else {
                         /* (3) */
+                       if (argc <= i)
+                               usage(blame_usage);
                         path = add_prefix(prefix, argv[i]);
                         if (i + 1 == argc - 1) {
                                 final_commit_name = argv[i + 1];

```

## Junio C Hamano, 2007-02-16 08:23

Subject: Re: [PATCH] git-blame: prevent argument parsing segfault
Message-ID: <7vsld67bp2.fsf@assigned-by-dhcp.cox.net>
URL: https://gitlist.dev/e/7vsld67bp2.fsf%40assigned-by-dhcp.cox.net
In-Reply-To: <45D55F6D.5090900@ray.fi>

```
Thanks.  Sign-off?

```
