Skip to content

Commit 8f34ae3

Browse files
committed
fix: passing complete buf size argument to _jsonb_escape
1 parent 9079145 commit 8f34ae3

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

json-build.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@ jsonb_key(jsonb *b, char buf[], size_t bufsize, const char key[], size_t len)
400400
case JSONB_OBJECT_KEY_OR_CLOSE: {
401401
enum jsonbcode ret;
402402
BUFFER_COPY_CHAR(b, '"', pos, buf, bufsize);
403-
ret = _jsonb_escape(&pos, buf + b->pos, bufsize, key, len);
403+
ret = _jsonb_escape(&pos, buf + b->pos, bufsize - b->pos, key, len);
404404
if (ret != JSONB_OK) return ret;
405405
BUFFER_COPY(b, "\":", 2, pos, buf, bufsize);
406406
STACK_HEAD(b, JSONB_OBJECT_VALUE);
@@ -551,7 +551,7 @@ jsonb_string(
551551
return JSONB_ERROR_INPUT;
552552
}
553553
BUFFER_COPY_CHAR(b, '"', pos, buf, bufsize);
554-
ret = _jsonb_escape(&pos, buf + b->pos, bufsize, str, len);
554+
ret = _jsonb_escape(&pos, buf + b->pos, bufsize - b->pos, str, len);
555555
if (ret != JSONB_OK) return ret;
556556
BUFFER_COPY_CHAR(b, '"', pos, buf, bufsize);
557557
STACK_HEAD(b, next_state);

0 commit comments

Comments
 (0)