Skip to content

Commit 0841493

Browse files
mackylegitster
authored andcommitted
mailinfo.c: move side-effects outside of assert
Since 6b4b013 (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 <[email protected]> Helped-by: Jeff King <[email protected]> Acked-by: Johannes Schindelin <[email protected]> Signed-off-by: Kyle J. McKay <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 6b4b013 commit 0841493

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

mailinfo.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -628,7 +628,8 @@ static void flush_inbody_header_accum(struct mailinfo *mi)
628628
{
629629
if (!mi->inbody_header_accum.len)
630630
return;
631-
assert(check_header(mi, &mi->inbody_header_accum, mi->s_hdr_data, 0));
631+
if (!check_header(mi, &mi->inbody_header_accum, mi->s_hdr_data, 0))
632+
die("BUG: inbody_header_accum, if not empty, must always contain a valid in-body header");
632633
strbuf_reset(&mi->inbody_header_accum);
633634
}
634635

0 commit comments

Comments
 (0)