Skip to content

Commit

Permalink
out_es: fix buffer size when converted_size is equal to 0. (#4414)
Browse files Browse the repository at this point in the history
In some case, ES_BULK_CHUNK is not enough to increase size of the
buffer

Fix #4412

Signed-off-by: Guillaume Smaha <[email protected]>
  • Loading branch information
GuillaumeSmaha authored Dec 9, 2021
1 parent 2d62c7d commit 0a061fb
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions plugins/out_es/es_bulk.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,14 @@ int es_bulk_append(struct es_bulk *bulk, char *index, int i_len,
if (converted_size == 0) {
/* converted_size = 0 causes div/0 */
flb_debug("[out_es] converted_size is 0");
append_size = ES_BULK_CHUNK;
append_size = required - available;
} else {
append_size = (whole_size - converted_size) /* rest of size to convert */
* (bulk->size / converted_size); /* = json size / msgpack size */
if (append_size < ES_BULK_CHUNK) {
/* append at least ES_BULK_CHUNK size */
append_size = ES_BULK_CHUNK;
}
}
if (append_size < ES_BULK_CHUNK) {
/* append at least ES_BULK_CHUNK size */
append_size = ES_BULK_CHUNK;
}
ptr = flb_realloc(bulk->ptr, bulk->size + append_size);
if (!ptr) {
Expand Down

0 comments on commit 0a061fb

Please sign in to comment.