diff options
-rw-r--r-- | src/render.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/render.c b/src/render.c index 20dca5f..5abd52e 100644 --- a/src/render.c +++ b/src/render.c @@ -171,7 +171,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'); } |