From 60d8ded6a6623ddceec76ea348879638b599ee1f Mon Sep 17 00:00:00 2001 From: Ben Trask Date: Tue, 7 Apr 2015 09:41:05 -0400 Subject: Check length before reading. --- src/blocks.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/blocks.c b/src/blocks.c index 4acd899..777356a 100644 --- a/src/blocks.c +++ b/src/blocks.c @@ -561,10 +561,10 @@ S_process_line(cmark_parser *parser, const unsigned char *buffer, size_t bytes) // Add a newline to the end if not present: // TODO this breaks abstraction: - if (parser->curline->ptr[parser->curline->size - 1] == '\n') { + if (parser->curline->size && parser->curline->ptr[parser->curline->size - 1] == '\n') { cmark_strbuf_truncate(parser->curline, parser->curline->size - 1); } - if (parser->curline->ptr[parser->curline->size - 1] == '\r') { + if (parser->curline->size && parser->curline->ptr[parser->curline->size - 1] == '\r') { cmark_strbuf_truncate(parser->curline, parser->curline->size - 1); } cmark_strbuf_putc(parser->curline, '\n'); -- cgit v1.2.3