Skip to content

Commit

Permalink
fix out-of-bounds read
Browse files Browse the repository at this point in the history
  • Loading branch information
NSEcho authored and kjk committed Sep 22, 2023
1 parent 7478c23 commit 14b1601
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
7 changes: 6 additions & 1 deletion parser/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,11 @@ func (p *Parser) Block(data []byte) {
// <div>
// ...
// </div>

if len(data) == 0 {
continue
}

if data[0] == '<' {
if i := p.html(data, true); i > 0 {
data = data[i:]
Expand Down Expand Up @@ -393,7 +398,7 @@ func (p *Parser) AddBlock(n ast.Node) ast.Node {
}

func (p *Parser) isPrefixHeading(data []byte) bool {
if data[0] != '#' {
if len(data) > 0 && data[0] != '#' {
return false
}

Expand Down
5 changes: 5 additions & 0 deletions parser/citation.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ func citation(p *Parser, data []byte, offset int) (int, ast.Node) {
}

citeType := ast.CitationTypeInformative

if len(citation) < 2 {
continue
}

j = 1
switch citation[j] {
case '!':
Expand Down

0 comments on commit 14b1601

Please sign in to comment.