Skip to content

Commit

Permalink
pack: do not multiply out_size by realloc_size
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.
  • Loading branch information
braydonk committed Aug 12, 2024
1 parent 13db2ee commit 8556ffe
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 @@ -810,7 +810,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 += realloc_size;
}
else {
flb_errno();
Expand Down

0 comments on commit 8556ffe

Please sign in to comment.