diff options
author | John MacFarlane <jgm@berkeley.edu> | 2015-12-28 10:50:20 -0800 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2015-12-28 10:50:20 -0800 |
commit | 6db3cb40add3800246bee8cd051baf4243e8ae44 (patch) | |
tree | 52716cb7140b01d2e941272c34f447ad21869558 /src/scanners.c | |
parent | 039913a8fe92b0f07b4bee418bc4df0ed85c7811 (diff) |
Another small optimization in _scan_at.
Check for offset greater than string length.
Diffstat (limited to 'src/scanners.c')
-rw-r--r-- | src/scanners.c | 5 |
1 files changed, 2 insertions, 3 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]; |