commit e61a8158cafb8bfad115eacfab296c76d141fe12
parent dee8142c37271ed1816b45fb67182486eb6991d3
Author: Martin Mitas <mity@morous.org>
Date: Sun, 27 Nov 2016 00:39:54 +0100
Fix some by-one errors when handling escapes.
Diffstat:
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/md4c/md4c.c b/md4c/md4c.c
@@ -1224,7 +1224,7 @@ md_is_link_label(MD_CTX* ctx, const MD_LINE* lines, int n_lines, OFF beg,
OFF line_end = lines[line_index].end;
while(off < line_end) {
- if(CH(off) == _T('\\') && off < ctx->size && (ISPUNCT(off+1) || ISNEWLINE(off+1))) {
+ if(CH(off) == _T('\\') && off+1 < ctx->size && (ISPUNCT(off+1) || ISNEWLINE(off+1))) {
if(contents_end == 0)
contents_beg = off;
contents_end = off + 2;
@@ -1286,7 +1286,7 @@ md_is_link_destination_A(MD_CTX* ctx, OFF beg, OFF max_end, OFF* p_end,
*p_contains_escape = FALSE;
while(off < max_end) {
- if(CH(off) == _T('\\') && off < max_end && ISPUNCT(off+1)) {
+ if(CH(off) == _T('\\') && off+1 < max_end && ISPUNCT(off+1)) {
*p_contains_escape = TRUE;
off += 2;
continue;
@@ -1320,7 +1320,7 @@ md_is_link_destination_B(MD_CTX* ctx, OFF beg, OFF max_end, OFF* p_end,
*p_contains_escape = FALSE;
while(off < max_end) {
- if(CH(off) == _T('\\') && off < max_end && ISPUNCT(off+1)) {
+ if(CH(off) == _T('\\') && off+1 < max_end && ISPUNCT(off+1)) {
*p_contains_escape = TRUE;
off += 2;
continue;
@@ -1406,7 +1406,7 @@ md_is_link_title(MD_CTX* ctx, const MD_LINE* lines, int n_lines, OFF beg,
OFF line_end = lines[line_index].end;
while(off < line_end) {
- if(CH(off) == _T('\\') && off < ctx->size && (ISPUNCT(off+1) || ISNEWLINE(off+1))) {
+ if(CH(off) == _T('\\') && off+1 < ctx->size && (ISPUNCT(off+1) || ISNEWLINE(off+1))) {
off++;
} else if(CH(off) == closer_char) {
/* Success. */