From 8d53b25485793ea94aad5e62773ad5bf477a5af6 Mon Sep 17 00:00:00 2001 From: Krzysztof Kowalczyk Date: Thu, 28 Mar 2024 16:47:14 +0000 Subject: [PATCH] make NormalizeNewlines() return a copy (fixes #305) --- parser/parser.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/parser/parser.go b/parser/parser.go index bd9e515..57f5d1d 100644 --- a/parser/parser.go +++ b/parser/parser.go @@ -907,6 +907,9 @@ func isListItem(d ast.Node) bool { } func NormalizeNewlines(d []byte) []byte { + res := make([]byte, 0, len(d)) + copy(res, d) + d = res wi := 0 n := len(d) for i := 0; i < n; i++ {