Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions src/buffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,14 @@ void cmark_strbuf_grow(cmark_strbuf *buf, bufsize_t target_size) {
bufsize_t new_size = target_size + target_size / 2;
new_size += 1;
new_size = (new_size + 7) & ~7;

buf->ptr = (unsigned char *)buf->mem->realloc(buf->asize ? buf->ptr : NULL,
new_size);

unsigned char *new_ptr = (unsigned char *)buf->mem->realloc(buf->asize ? buf->ptr : NULL, new_size);

if (new_ptr != NULL) {
// Only update the buffer if realloc succeeded
buf->ptr = new_ptr;
}

buf->asize = new_size;
}

Expand Down