fix string allocation issue

pull/2/head
cosmonaut 2022-07-26 12:44:45 -07:00
parent b0265a0372
commit c6ce7c7a00
1 changed files with 1 additions and 1 deletions

View File

@ -58,7 +58,7 @@ JsonBuilder* JsonBuilder_Init()
void JsonBuilder_Internal_MaybeExpand(JsonBuilder *builder, size_t len) void JsonBuilder_Internal_MaybeExpand(JsonBuilder *builder, size_t len)
{ {
if (builder->capacity < builder->index + len) if (builder->capacity < builder->index + len + 1)
{ {
builder->capacity = max(builder->index + len, builder->capacity * 2); builder->capacity = max(builder->index + len, builder->capacity * 2);
builder->string = realloc(builder->string, builder->capacity); builder->string = realloc(builder->string, builder->capacity);