From 90d0c3316c1bc0f2b904e758a4446c1cd111bc63 Mon Sep 17 00:00:00 2001 From: Robert Griesemer Date: Tue, 18 May 2010 16:31:49 -0700 Subject: [PATCH] big: bug fix for division Fixes #784. R=rsc CC=golang-dev https://golang.org/cl/1196043 --- src/pkg/big/nat.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/pkg/big/nat.go b/src/pkg/big/nat.go index 56f3c444ef4..668a626891d 100755 --- a/src/pkg/big/nat.go +++ b/src/pkg/big/nat.go @@ -528,10 +528,15 @@ func (z nat) divLarge(u, uIn, v nat) (q, r nat) { n := len(v) m := len(uIn) - n + // determine if z can be reused + if alias(z, uIn) || alias(z, v) { + z = nil // z is an alias for uIn or v - cannot reuse + } q = z.make(m + 1) + qhatv := make(nat, n+1) - if alias(u, uIn) { - u = nil // u is an alias for uIn - cannot reuse + if alias(u, uIn) || alias(u, v) { + u = nil // u is an alias for uIn or v - cannot reuse } u = u.make(len(uIn) + 1) u.clear()