rev-parse: check i before using argv[i] against argc
commita43219f2aaa39fbc53ba0aee2481e1cca3c0e649
authorDavid Sharp <dhsharp@google.com>
Tue, 28 Jan 2014 21:21:00 +0000 (28 13:21 -0800)
committerJunio C Hamano <gitster@pobox.com>
Tue, 28 Jan 2014 22:10:06 +0000 (28 14:10 -0800)
tree4f8d96983cf247a21d48df911ccb1a71a750074f
parentd2446dfd7f3b3f8948142cfb07a0270e2497d93f
rev-parse: check i before using argv[i] against argc

The --prefix, --default, and --resolve-git-dir options to
git-rev-parse require an argument, but when given no argument,
the code uses the NULL read from argv[argc] without checking,
leading to a segfault.

Instead, check first and die() with an error message.

Signed-off-by: David Sharp <dhsharp@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/rev-parse.c