diff --git a/modules/markup/html.go b/modules/markup/html.go
index 314231cc19..2958dc9646 100644
--- a/modules/markup/html.go
+++ b/modules/markup/html.go
@@ -592,7 +592,8 @@ func replaceContentList(node *html.Node, i, j int, newNodes []*html.Node) {
func mentionProcessor(ctx *RenderContext, node *html.Node) {
start := 0
- for node != nil {
+ nodeStop := node.NextSibling
+ for node != nodeStop {
found, loc := references.FindFirstMentionBytes(util.UnsafeStringToBytes(node.Data[start:]))
if !found {
node = node.NextSibling