diff -r a91437fe94b6 -r 4ef184875799 src/lib-storage/index/index-mail-headers.c --- a/src/lib-storage/index/index-mail-headers.c Wed Nov 20 14:38:55 2013 +0200 +++ b/src/lib-storage/index/index-mail-headers.c Wed Nov 20 14:50:53 2013 +0200 @@ -653,8 +653,8 @@ /* cached. skip "header name: " parts in dest. */ for (i = 0; i < len; i++) { if (data[i] == ':') { - while (IS_LWSP(data[i+1])) i++; - if (i+1 != len) i++; + i++; + while (i < len && IS_LWSP(data[i])) i++; /* @UNSAFE */ len = get_header_size(dest, i); diff -r 4ef184875799 -r 47923cfd4b56 src/lib-storage/index/index-mail-headers.c --- a/src/lib-storage/index/index-mail-headers.c Wed Nov 20 14:50:53 2013 +0200 +++ b/src/lib-storage/index/index-mail-headers.c Wed Nov 20 15:07:26 2013 +0200 @@ -603,7 +603,7 @@ unsigned char *data; unsigned int field_idx; string_t *dest; - size_t i, len; + size_t i, len, len2; int ret; ARRAY(const char *) header_values; @@ -657,10 +657,10 @@ while (i < len && IS_LWSP(data[i])) i++; /* @UNSAFE */ - len = get_header_size(dest, i); - data[i + len] = '\0'; + len2 = get_header_size(dest, i); + data[i + len2] = '\0'; value = (const char *)data + i; - i += len + 1; + i += len2 + 1; array_append(&header_values, &value, 1); }