summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2016-10-11 14:40:05 +0200
committerJohn MacFarlane <jgm@berkeley.edu>2016-10-11 14:45:01 +0200
commit89c8d703d258cef7cbe566eab537fb8f30aad7ed (patch)
treeff0a2b2525843675f9168f181607dcbdac8b535e /src
parent1f51da22e4d56ae0f0bc3ae75817e99a91038226 (diff)
Changed logic for null/eol checks.
- only check once for "not at end of line" - check for null before we check for newline characters (the previous patch would fail for NULL + CR) See #160.
Diffstat (limited to 'src')
-rw-r--r--src/blocks.c23
1 files changed, 14 insertions, 9 deletions
diff --git a/src/blocks.c b/src/blocks.c
index a88c168..4a6b7ef 100644
--- a/src/blocks.c
+++ b/src/blocks.c
@@ -569,16 +569,21 @@ static void S_parser_feed(cmark_parser *parser, const unsigned char *buffer,
}
buffer += chunk_len;
- // skip over line ending characters:
- if (buffer < end && *buffer == '\r') {
- buffer++;
- if (buffer == end)
- parser->last_buffer_ended_with_cr = true;
+ if (buffer < end) {
+ if (*buffer == '\0') {
+ // skip over NULL
+ buffer++;
+ } else {
+ // skip over line ending characters
+ if (*buffer == '\r') {
+ buffer++;
+ if (buffer == end)
+ parser->last_buffer_ended_with_cr = true;
+ }
+ if (*buffer == '\n')
+ buffer++;
+ }
}
- if (buffer < end && *buffer == '\0')
- buffer++;
- else if (buffer < end && *buffer == '\n')
- buffer++;
}
}