Skip to content

Commit

Permalink
pack: do not multiply out_size by realloc_size (fluent#9193)
Browse files Browse the repository at this point in the history
In `flb_msgpack_raw_to_json_sds`, when the buffer is reallocated it calls `flb_sds_increase`. This increases the length by adding the `len` argument to the length and reallocating the sds object. After doing this, the `out_size` is multiplied by `realloc_size`. This does not match reality, as what happened in the reallocation was additive not multiplicative. This commit corrects the inconsistency.

Signed-off-by: braydonk <[email protected]>
  • Loading branch information
braydonk authored and AndrewChubatiuk committed Sep 24, 2024
1 parent 8410c97 commit 1d4e72e
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/flb_pack.c
Original file line number Diff line number Diff line change
Expand Up @@ -811,7 +811,7 @@ flb_sds_t flb_msgpack_raw_to_json_sds(const void *in_buf, size_t in_size)
tmp_buf = flb_sds_increase(out_buf, realloc_size);
if (tmp_buf) {
out_buf = tmp_buf;
out_size *= realloc_size;
out_size = flb_sds_alloc(out_buf);
}
else {
flb_errno();
Expand Down

0 comments on commit 1d4e72e

Please sign in to comment.