Skip to content

Commit 5c269c9

Browse files
committed
Fix array indexing issue in markdown.cpp
1 parent 32fdb78 commit 5c269c9

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/markdown.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1649,7 +1649,7 @@ int Markdown::Private::processCodeSpan(std::string_view data,size_t offset)
16491649
i++;
16501650
if (nb==1) // `...`
16511651
{
1652-
if (end<size && data[end+1]=='`') // skip over `` inside `...`
1652+
if (end+1<size && data[end+1]=='`') // skip over `` inside `...`
16531653
{
16541654
AUTO_TRACE_ADD("case1.1");
16551655
// skip
@@ -1664,7 +1664,7 @@ int Markdown::Private::processCodeSpan(std::string_view data,size_t offset)
16641664
}
16651665
else if (i==nb) // ``...``
16661666
{
1667-
if (end<size && data[end+1]=='`') // do greedy match
1667+
if (end+1<size && data[end+1]=='`') // do greedy match
16681668
{
16691669
// skip this quote and use the next one to terminate the sequence, e.g. ``X`Y```
16701670
i--;
@@ -1688,15 +1688,15 @@ int Markdown::Private::processCodeSpan(std::string_view data,size_t offset)
16881688
pc = '\n';
16891689
i = 0;
16901690
}
1691-
else if (data[end]=='\'' && nb==1 && (end==size-1 || (end+1<size && data[end+1]!='\'' && !isIdChar(data[end+1]))))
1691+
else if (data[end]=='\'' && nb==1 && (end+1==size || (end+1<size && data[end+1]!='\'' && !isIdChar(data[end+1]))))
16921692
{ // look for quoted strings like 'some word', but skip strings like `it's cool`
16931693
out+="&lsquo;";
16941694
out+=data.substr(nb,end-nb);
16951695
out+="&rsquo;";
16961696
AUTO_TRACE_EXIT("quoted end={}",end+1);
16971697
return static_cast<int>(end+1);
16981698
}
1699-
else if (data[end]=='\'' && nb==2 && end<size-1 && data[end+1]=='\'')
1699+
else if (data[end]=='\'' && nb==2 && end+1<size && data[end+1]=='\'')
17001700
{ // look for '' to match a ``
17011701
out+="&ldquo;";
17021702
out+=data.substr(nb,end-nb);

0 commit comments

Comments
 (0)