]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-mail: message_header_encode() cleanup - simplify pointer arithmetic
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Wed, 13 Sep 2017 20:35:04 +0000 (23:35 +0300)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Wed, 13 Sep 2017 20:35:43 +0000 (23:35 +0300)
This should make static analyzers happier.

src/lib-mail/message-header-encode.c

index 4fef8f4fa4578434dd9cdfdcb785b632934c5a1f..c8586e98700cff1ef5f03cdf0815112da79bdb22 100644 (file)
@@ -194,9 +194,11 @@ void message_header_encode_data(const unsigned char *input, unsigned int len,
           recursively. */
        next_line_input = memchr(input, '\n', len);
        if (next_line_input != NULL) {
-               if (next_line_input != input && next_line_input[-1] == '\r')
-                       next_line_input--;
                cur_line_len = next_line_input - input;
+               if (cur_line_len > 0 && input[cur_line_len-1] == '\r') {
+                       cur_line_len--;
+                       next_line_input = input + cur_line_len;
+               }
                next_line_len = len - cur_line_len;
                len = cur_line_len;
        }