diff options
author | Junio C Hamano <gitster@pobox.com> | 2008-07-16 22:42:04 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2008-07-16 22:42:04 -0700 |
commit | 1e102bf7c83281944ffd9202a7d35c514e4a5644 (patch) | |
tree | d7bcd889fc3e43e3a4637c5647a9887ed1b46b8f /builtin-mailinfo.c | |
parent | 3bf0dd1f4e75ee1591169b687ce04dff00ae2e3e (diff) | |
download | git-1e102bf7c83281944ffd9202a7d35c514e4a5644.tar.gz git-1e102bf7c83281944ffd9202a7d35c514e4a5644.tar.xz |
mailinfo: off-by-one fix for [PATCH (foobar)] removal from Subject: line
A patch title "[PATCH] 1" was sanitized by the original code by stripping
the "[PATCH]" from the front, but after the conversion to use strbuf this
behaviour was broken due to a counting error.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin-mailinfo.c')
-rw-r--r-- | builtin-mailinfo.c | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/builtin-mailinfo.c b/builtin-mailinfo.c index 4b8261552..b99a5b6f9 100644 --- a/builtin-mailinfo.c +++ b/builtin-mailinfo.c @@ -225,10 +225,9 @@ static void cleanup_subject(struct strbuf *subject) continue; case '[': if ((pos = strchr(subject->buf, ']'))) { - remove = pos - subject->buf + 1; - /* Don't remove too much. */ - if (remove <= (subject->len - remove + 1) * 2) { - strbuf_remove(subject, 0, remove); + remove = pos - subject->buf; + if (remove <= (subject->len - remove) * 2) { + strbuf_remove(subject, 0, remove + 1); continue; } } else |