]> Cypherpunks repositories - gostls13.git/commit
math/big: avoid negative slice size in nat.rem
authorRuss Cox <rsc@golang.org>
Wed, 5 Mar 2025 19:43:44 +0000 (14:43 -0500)
committerRuss Cox <rsc@golang.org>
Thu, 6 Mar 2025 16:08:34 +0000 (08:08 -0800)
commit70dcc78871ee47a6b181a99e6bad70b3454e8aec
treef0ffaf3fd493ab6f375990901a4df4d360c46c72
parent5e0dbec7c99cb1e62c6e61b8f64f5b211aae67fc
math/big: avoid negative slice size in nat.rem

In a division, normally the answer to N digits / D digits has N-D digits,
but not when N-D is negative. Fix the calculation of the number of
digits for the temporary in nat.rem not to be negative.

Fixes #72043.

Change-Id: Ib9faa430aeb6c5f4c4a730f1ec631d2bf3f7472c
Reviewed-on: https://go-review.googlesource.com/c/go/+/655156
Reviewed-by: Robert Griesemer <gri@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
src/math/big/alias_test.go
src/math/big/natdiv.go