diff options
author | Vicent Marti <tanoku@gmail.com> | 2014-09-10 19:46:34 +0200 |
---|---|---|
committer | Vicent Marti <tanoku@gmail.com> | 2014-09-10 19:46:34 +0200 |
commit | 7c2a062cdf9c0514cdf32f4f8bd07cf52d183c8b (patch) | |
tree | 5308d25a9d8dfae28766a735150d2284506c7f4a | |
parent | 79e7a4bbf7055e33b346564db769f03e85f98988 (diff) |
Do not use strchr for span searches
Strchr will return a valid pointer for '\0' when searching a static
string, as the NULL byte is part of the string.
-rw-r--r-- | src/inlines.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/inlines.c b/src/inlines.c index 3040f09..cd2d124 100644 --- a/src/inlines.c +++ b/src/inlines.c @@ -767,10 +767,13 @@ node_inl *parse_chunk_inlines(chunk *chunk, reference_map *refmap) static int subject_find_special_char(subject *subj) { + static const char CHARS[] = "\n\\`&_*[]<!"; + static const size_t CHARS_SIZE = sizeof(CHARS) - 1; + int n = subj->pos + 1; while (n < subj->input.len) { - if (strchr("\n\\`&_*[]<!", subj->input.data[n])) + if (memchr(CHARS, subj->input.data[n], CHARS_SIZE)) return n; n++; } |