Fix fenced code extn modifying data beyond slice

pull/73/head
Dave Johnston 2014-05-02 23:05:06 +01:00
parent c76eb63418
commit 852c1967b9
1 changed files with 4 additions and 1 deletions

View File

@ -331,7 +331,10 @@ func firstPass(p *parser, input []byte) []byte {
if p.flags&EXTENSION_FENCED_CODE != 0 {
// when last line was none blank and a fenced code block comes after
if beg >= lastFencedCodeBlockEnd {
if i := p.fencedCode(&out, append(input[beg:], '\n'), false); i > 0 {
// tmp var so we don't modify beyond bounds of `input`
var tmp = make([]byte, len(input[beg:]))
copy(tmp, input[beg:])
if i := p.fencedCode(&out, append(tmp, '\n'), false); i > 0 {
if !lastLineWasBlank {
out.WriteByte('\n') // need to inject additional linebreak
}