parser: avoid panic

This commit is contained in:
Noah Hellman 2023-02-01 18:05:25 +01:00
parent c4a3acaf70
commit a5d88b64ae

View file

@ -236,8 +236,10 @@ impl<'s> InlineSpans<'s> {
return CowStr::Borrowed(&sp.of(src)[span.start() - a..span.end() - a]); return CowStr::Borrowed(&sp.of(src)[span.start() - a..span.end() - a]);
} }
(span.start() - a)..sp.len() (span.start() - a)..sp.len()
} else { } else if a <= span.end() {
0..sp.len().min(span.end() - a) 0..sp.len().min(span.end() - a)
} else {
break;
}; };
s.push_str(&sp.of(src)[r]); s.push_str(&sp.of(src)[r]);
} }