From 191a6bfc5e99911f905cb582b676b5502c7b5aad Mon Sep 17 00:00:00 2001 From: Robert Griesemer Date: Thu, 2 Jun 2011 11:07:41 -0700 Subject: [PATCH] big: do not modify divisor Fixes #1907. R=rsc CC=golang-dev https://golang.org/cl/4527096 --- src/pkg/big/nat.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/pkg/big/nat.go b/src/pkg/big/nat.go index 4f17e3690c0..db02a43c2e1 100755 --- a/src/pkg/big/nat.go +++ b/src/pkg/big/nat.go @@ -551,7 +551,12 @@ func (z nat) divLarge(u, uIn, v nat) (q, r nat) { // D1. shift := Word(leadingZeros(v[n-1])) - shlVW(v, v, shift) + if shift > 0 { + // do not modify v, it may be used by another goroutine simultaneously + v1 := make(nat, n) + shlVW(v1, v, shift) + v = v1 + } u[len(uIn)] = shlVW(u[0:len(uIn)], uIn, shift) // D2. @@ -592,7 +597,6 @@ func (z nat) divLarge(u, uIn, v nat) (q, r nat) { q = q.norm() shrVW(u, u, shift) - shrVW(v, v, shift) r = u.norm() return q, r