{
bool crlf = HAS_ALL_BITS(enc->flags, BASE64_ENCODE_FLAG_CRLF);
size_t out_size = base64_encode_get_out_size(enc, src_size);
- size_t line_part, lines;
if (src_size == 0) {
/* last block */
}
}
- if (enc->max_line_len == SIZE_MAX)
- return out_size;
+ if (enc->max_line_len < SIZE_MAX) {
+ size_t line_part, lines;
- /* Calculate how many line endings must be added */
- lines = out_size / enc->max_line_len;
- line_part = out_size % enc->max_line_len;
- if (enc->cur_line_len > (enc->max_line_len - line_part))
- lines++;
+ /* Calculate how many line endings must be added */
+ lines = out_size / enc->max_line_len;
+ line_part = out_size % enc->max_line_len;
+ if (enc->cur_line_len > (enc->max_line_len - line_part))
+ lines++;
+
+ out_size += lines * (crlf ? 2 : 1);
+ }
- out_size += lines * (crlf ? 2 : 1);
return out_size;
}