@@ -77,6 +77,18 @@ static int multiline_load_parsers(struct flb_tail_config *ctx)
7777 return 0 ;
7878}
7979
80+ static void adjust_buffer_for_2bytes_alignments (struct flb_tail_config * ctx )
81+ {
82+ if ((ctx -> buf_max_size - 1 ) % 2 ) {
83+ ctx -> buf_max_size ++ ;
84+ flb_plg_info (ctx -> ins , "adjusted buf_max_size to %zd" , ctx -> buf_max_size );
85+ }
86+ if ((ctx -> buf_chunk_size - 1 ) % 2 ) {
87+ ctx -> buf_chunk_size ++ ;
88+ flb_plg_info (ctx -> ins , "adjusted buf_chunk_size to %zd" , ctx -> buf_chunk_size );
89+ }
90+ }
91+
8092struct flb_tail_config * flb_tail_config_create (struct flb_input_instance * ins ,
8193 struct flb_config * config )
8294{
@@ -190,14 +202,17 @@ struct flb_tail_config *flb_tail_config_create(struct flb_input_instance *ins,
190202 if (tmp ) {
191203 if (strcasecmp (tmp , "auto" ) == 0 ) {
192204 ctx -> preferred_input_encoding = FLB_SIMDUTF_ENCODING_TYPE_UNICODE_AUTO ;
205+ adjust_buffer_for_2bytes_alignments (ctx );
193206 }
194207 else if (strcasecmp (tmp , "utf-16le" ) == 0 ||
195208 strcasecmp (tmp , "utf16-le" ) == 0 ) {
196209 ctx -> preferred_input_encoding = FLB_SIMDUTF_ENCODING_TYPE_UTF16_LE ;
210+ adjust_buffer_for_2bytes_alignments (ctx );
197211 }
198212 else if (strcasecmp (tmp , "utf-16be" ) == 0 ||
199213 strcasecmp (tmp , "utf16-be" ) == 0 ) {
200214 ctx -> preferred_input_encoding = FLB_SIMDUTF_ENCODING_TYPE_UTF16_BE ;
215+ adjust_buffer_for_2bytes_alignments (ctx );
201216 }
202217 else {
203218 flb_plg_error (ctx -> ins , "invalid encoding 'unicode.encoding' value" );
0 commit comments