diff options
author | Robert Griesemer <gri@golang.org> | 2010-05-18 16:31:49 -0700 |
---|---|---|
committer | Robert Griesemer <gri@golang.org> | 2010-05-18 16:31:49 -0700 |
commit | e46d0d6fa36a574317319a4ab0fb0711969d54c2 (patch) | |
tree | 780725746868b60555468ccceaebf9ef786f32cf /src/pkg/big | |
parent | 27716934e0e621817fe78cd01d4b05971bdcbdf6 (diff) | |
download | golang-e46d0d6fa36a574317319a4ab0fb0711969d54c2.tar.gz |
big: bug fix for division
Fixes issue 784.
R=rsc
CC=golang-dev
http://codereview.appspot.com/1196043
Diffstat (limited to 'src/pkg/big')
-rwxr-xr-x | src/pkg/big/nat.go | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/pkg/big/nat.go b/src/pkg/big/nat.go index 56f3c444e..668a62689 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() |