From 4d9ab00d0cd84ad2ae9937a2e3aa8bea41146d6e Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Thu, 30 Mar 2017 00:09:16 +0100 Subject: [PATCH] [Minor] Fix some corner cases of folding --- src/libutil/str_util.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/libutil/str_util.c b/src/libutil/str_util.c index 10f5d54e3..cb110e136 100644 --- a/src/libutil/str_util.c +++ b/src/libutil/str_util.c @@ -1092,7 +1092,6 @@ rspamd_header_value_fold (const gchar *name, cur_len = 0; } else { - g_assert (p > c); /* Skip space if needed */ if (g_ascii_isspace (*c) && p > c) { c ++; @@ -1111,8 +1110,13 @@ rspamd_header_value_fold (const gchar *name, break; } - g_string_append_len (res, c, p - c); - cur_len = p - c; + if (p > c) { + g_string_append_len (res, c, p - c); + cur_len = p - c; + } + else { + cur_len = 0; + } } first_token = TRUE; -- 2.39.5