diff options
author | Ben Trask <bentrask@comcast.net> | 2015-04-07 09:41:05 -0400 |
---|---|---|
committer | Ben Trask <bentrask@comcast.net> | 2015-04-07 09:41:05 -0400 |
commit | 60d8ded6a6623ddceec76ea348879638b599ee1f (patch) | |
tree | 9d908c62e495755277e3fb0475c2ccb67cc634bc /src/blocks.c | |
parent | 271d8a16e0fa62aa8d6eace9b1931cc4beb27e06 (diff) |
Check length before reading.
Diffstat (limited to 'src/blocks.c')
-rw-r--r-- | src/blocks.c | 4 |
1 files changed, 2 insertions, 2 deletions
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'); |