aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVicent Marti <tanoku@gmail.com>2014-09-10 19:46:34 +0200
committerVicent Marti <tanoku@gmail.com>2014-09-10 19:46:34 +0200
commit7c2a062cdf9c0514cdf32f4f8bd07cf52d183c8b (patch)
tree5308d25a9d8dfae28766a735150d2284506c7f4a
parent79e7a4bbf7055e33b346564db769f03e85f98988 (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.c5
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++;
}