Skip to content

Commit

Permalink
leave more room at end of buffer for cornercases
Browse files Browse the repository at this point in the history
  • Loading branch information
Hannes Gredler committed Dec 19, 2023
1 parent 70016a7 commit 0dec512
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions code/lspgen/src/lspgen_ctrl.c
Original file line number Diff line number Diff line change
Expand Up @@ -295,11 +295,9 @@ lspgen_ctrl_write_cb(timer_s *timer)
buffer_left = ctx->ctrl_io_buf.size - ctx->ctrl_io_buf.idx;

/*
* Hexdumping doubles the data,
* plus 4 bytes for two quotation marks, comma and whitespace,
* plus 6 bytes for the json footer.
* Close the JSON message and socket once 99% of the buffer have been consumed.
*/
if (buffer_left < ((packet->buf[0].idx * 2) + 4 + 6)) {
if (buffer_left < (CTRL_SOCKET_BUFSIZE/100)) {

/* no space, close the JSON datagram and continue later */
LOG_NOARG(NORMAL, "End of buffer\n");
Expand Down

0 comments on commit 0dec512

Please sign in to comment.