Skip to content

Commit 8ddb6bb

Browse files
authored
Merge pull request #10891 from lahwaacz/markdown-fix-overflow
Fix buffer overflow in Markdown parser
2 parents 2dccfe1 + 28b51a7 commit 8ddb6bb

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/markdown.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -661,6 +661,11 @@ size_t Markdown::Private::findEmphasisChar(std::string_view data, char c, size_t
661661
data[i]!='\\' && data[i]!='@' &&
662662
!(data[i]=='/' && data[i-1]=='<') && // html end tag also ends emphasis
663663
data[i]!='\n') i++;
664+
// avoid overflow (unclosed emph token)
665+
if (i==size)
666+
{
667+
return 0;
668+
}
664669
//printf("findEmphasisChar: data=[%s] i=%d c=%c\n",data,i,data[i]);
665670

666671
// not counting escaped chars or characters that are unlikely

0 commit comments

Comments
 (0)