summaryrefslogtreecommitdiff
path: root/src/scanners.re
diff options
context:
space:
mode:
Diffstat (limited to 'src/scanners.re')
-rw-r--r--src/scanners.re14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/scanners.re b/src/scanners.re
index 0037bc4..75417a1 100644
--- a/src/scanners.re
+++ b/src/scanners.re
@@ -6,11 +6,17 @@ bufsize_t _scan_at(bufsize_t (*scanner)(const unsigned char *), cmark_chunk *c,
{
bufsize_t res;
unsigned char *ptr = (unsigned char *)c->data;
- unsigned char lim = ptr[c->len];
+ unsigned char zero = '\0';
- ptr[c->len] = '\0';
- res = scanner(ptr + offset);
- ptr[c->len] = lim;
+ if (ptr == NULL) {
+ res = scanner(&zero);
+ } else {
+ unsigned char lim = ptr[c->len];
+
+ ptr[c->len] = '\0';
+ res = scanner(ptr + offset);
+ ptr[c->len] = lim;
+ }
return res;
}