Skip to content

Commit

Permalink
fix: passing complete buf size argument to _jsonb_escape
Browse files Browse the repository at this point in the history
  • Loading branch information
anibalportero committed Aug 31, 2022
1 parent 9079145 commit 8f34ae3
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions json-build.h
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ jsonb_key(jsonb *b, char buf[], size_t bufsize, const char key[], size_t len)
case JSONB_OBJECT_KEY_OR_CLOSE: {
enum jsonbcode ret;
BUFFER_COPY_CHAR(b, '"', pos, buf, bufsize);
ret = _jsonb_escape(&pos, buf + b->pos, bufsize, key, len);
ret = _jsonb_escape(&pos, buf + b->pos, bufsize - b->pos, key, len);
if (ret != JSONB_OK) return ret;
BUFFER_COPY(b, "\":", 2, pos, buf, bufsize);
STACK_HEAD(b, JSONB_OBJECT_VALUE);
Expand Down Expand Up @@ -551,7 +551,7 @@ jsonb_string(
return JSONB_ERROR_INPUT;
}
BUFFER_COPY_CHAR(b, '"', pos, buf, bufsize);
ret = _jsonb_escape(&pos, buf + b->pos, bufsize, str, len);
ret = _jsonb_escape(&pos, buf + b->pos, bufsize - b->pos, str, len);
if (ret != JSONB_OK) return ret;
BUFFER_COPY_CHAR(b, '"', pos, buf, bufsize);
STACK_HEAD(b, next_state);
Expand Down

0 comments on commit 8f34ae3

Please sign in to comment.