diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/scanners.c | 5 | ||||
-rw-r--r-- | src/scanners.re | 2 |
2 files changed, 3 insertions, 4 deletions
diff --git a/src/scanners.c b/src/scanners.c index c0df18b..ae4125f 100644 --- a/src/scanners.c +++ b/src/scanners.c @@ -7,10 +7,9 @@ bufsize_t _scan_at(bufsize_t (*scanner)(const unsigned char *), cmark_chunk *c, bufsize_t offset) { bufsize_t res; unsigned char *ptr = (unsigned char *)c->data; - unsigned char zero = '\0'; - if (ptr == NULL) { - res = scanner(&zero); + if (ptr == NULL || offset > c->len) { + return 0; } else { unsigned char lim = ptr[c->len]; diff --git a/src/scanners.re b/src/scanners.re index befe7d0..8176590 100644 --- a/src/scanners.re +++ b/src/scanners.re @@ -7,7 +7,7 @@ bufsize_t _scan_at(bufsize_t (*scanner)(const unsigned char *), cmark_chunk *c, bufsize_t res; unsigned char *ptr = (unsigned char *)c->data; - if (ptr == NULL) { + if (ptr == NULL || offset > c->len) { return 0; } else { unsigned char lim = ptr[c->len]; |