# HG changeset patch
# User meillo@marmaro.de
# Date 1307087537 -7200
# Node ID ec3fe72a3e995f335f108c2aa21dbb6cec460fe9
# Parent  100a5d7e196a08ce2995b88c11f1c8ed2f034dc1
Fixed an important bug with folded headers!
g_strconcat() returns a *copy* of the string, but hdr->value still
pointed to the old header (which probably was a memory leak, too).
If the folded part had been quite small it was likely that the new
string was at the same position as the old one, thus making everything
go well. But if pretty long headers were folded several times it was
likely that the new string was allocated somewhere else in memory,
thus breaking things. In result mails to lots of recipients (folded
header) were frequently only sent to the ones in the first line. Sorry
for the inconvenience.

diff -r 100a5d7e196a -r ec3fe72a3e99 src/accept.c
--- a/src/accept.c	Fri Jul 23 10:47:08 2010 +0200
+++ b/src/accept.c	Fri Jun 03 09:52:17 2011 +0200
@@ -132,7 +132,11 @@
 				if (line1[0] == ' ' || line1[0] == '\t') {
 					/* continuation of 'folded' header: */
 					if (hdr) {
-						hdr->header = g_strconcat(hdr->header, line1, NULL);
+						char* cp;
+						cp = g_strconcat(hdr->header, line1, NULL);
+						hdr->value = cp + (hdr->value - hdr->header);
+						free(hdr->header);
+						hdr->header = cp;
 					}
 
 				} else if (line1[0] == '\n') {