summaryrefslogtreecommitdiff
path: root/mailinfo.c
diff options
context:
space:
mode:
authorKyle J. McKay <mackyle@gmail.com>2016-12-19 23:13:00 (GMT)
committerJunio C Hamano <gitster@pobox.com>2016-12-20 17:30:01 (GMT)
commit08414938a26f66988418dfdac03a62b97450056d (patch)
tree651d4edf07f9f75619708547bbbeb8be4d398392 /mailinfo.c
parent6b4b013f1884a3b5e67877d65a9f1da598ab4a6f (diff)
downloadgit-08414938a26f66988418dfdac03a62b97450056d.zip
git-08414938a26f66988418dfdac03a62b97450056d.tar.gz
git-08414938a26f66988418dfdac03a62b97450056d.tar.bz2
mailinfo.c: move side-effects outside of assert
Since 6b4b013f18 (mailinfo: handle in-body header continuations, 2016-09-20, v2.11.0) mailinfo.c has contained new code with an assert of the form: assert(call_a_function(...)) The function in question, check_header, has side effects. This means that when NDEBUG is defined during a release build the function call is omitted entirely, the side effects do not take place and tests (fortunately) start failing. Since the only time that mi->inbody_header_accum is appended to is in check_inbody_header, and appending onto a blank mi->inbody_header_accum always happens when is_inbody_header is true, this guarantees a prefix that causes check_header to always return true. Therefore replace the assert with an if !check_header + DIE combination to reflect this. Helped-by: Jonathan Tan <jonathantanmy@google.com> Helped-by: Jeff King <peff@peff.net> Acked-by: Johannes Schindelin <Johannes.Schindelin@gmx.de> Signed-off-by: Kyle J. McKay <mackyle@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'mailinfo.c')
-rw-r--r--mailinfo.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/mailinfo.c b/mailinfo.c
index 2275b28..e92aff9 100644
--- a/mailinfo.c
+++ b/mailinfo.c
@@ -628,7 +628,8 @@ static void flush_inbody_header_accum(struct mailinfo *mi)
{
if (!mi->inbody_header_accum.len)
return;
- assert(check_header(mi, &mi->inbody_header_accum, mi->s_hdr_data, 0));
+ if (!check_header(mi, &mi->inbody_header_accum, mi->s_hdr_data, 0))
+ die("BUG: inbody_header_accum, if not empty, must always contain a valid in-body header");
strbuf_reset(&mi->inbody_header_accum);
}