Code

for-each-ref: fix segfault in copy_email
authorJeff King <peff@peff.net>
Mon, 18 May 2009 17:58:11 +0000 (13:58 -0400)
committerJunio C Hamano <gitster@pobox.com>
Wed, 20 May 2009 07:06:19 +0000 (00:06 -0700)
commite64c1b0053f2dc4fc5b434a9806b90318bac9592
treea531a2cb6275af5df03dc003091eeceaf5d8891d
parent5acb3e5012966cc11e54f50e0592b3639bade02c
for-each-ref: fix segfault in copy_email

You can trigger a segfault in git.git by doing:

  git for-each-ref --format='%(taggeremail)' refs/tags/v0.99

The v0.99 tag is special in that it contains no "tagger"
header.

The bug is obvious in copy_email, which carefully checks to
make sure the result of a strchr is non-NULL, but only after
already having used it to perform other work. The fix is to
move the check up.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin-for-each-ref.c