summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/render.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/render.c b/src/render.c
index dd65d3b..a73d6f8 100644
--- a/src/render.c
+++ b/src/render.c
@@ -172,7 +172,7 @@ char *cmark_render(cmark_node *root, int options, int width,
}
// ensure final newline
- if (renderer.buffer->ptr[renderer.buffer->size - 1] != '\n') {
+ if (renderer.buffer->size == 0 || renderer.buffer->ptr[renderer.buffer->size - 1] != '\n') {
cmark_strbuf_putc(renderer.buffer, '\n');
}