From 55b149054da0be958a2160cb3a6d1ded8dbb4847 Mon Sep 17 00:00:00 2001 From: Niklas Fasching Date: Sun, 28 Jun 2020 21:26:02 +0200 Subject: [PATCH] fuzz: Fix index out of range for results without content Offending crasher: "\n\n\n\n\n\n\n\n\n#+RESULTS:" --- org/block.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/org/block.go b/org/block.go index 6f8a98f..11b135f 100644 --- a/org/block.go +++ b/org/block.go @@ -105,6 +105,9 @@ func (d *Document) parseExample(i int, parentStop stopFn) (int, Node) { } func (d *Document) parseResult(i int, parentStop stopFn) (int, Node) { + if i+1 >= len(d.tokens) { + return 0, nil + } consumed, node := d.parseOne(i+1, parentStop) return consumed + 1, Result{node} }