summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog6
-rw-r--r--doc/gmp.texi7
-rw-r--r--mpz/gcdext.c2
3 files changed, 11 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index b41543dad..a6698399b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2011-05-09 Niels Möller <nisse@lysator.liu.se>
+
+ * mpz/gcdext.c (mpz_gcdext): Increased sp allocation to bsize+1 limbs.
+ * doc/gmp.texi (mpn_gcdext): Fixed documentation of allocation
+ requirements; one extra limb is still needed for S.
+
2011-05-09 Torbjorn Granlund <tege@gmplib.org>
* mpn/x86/fat/gmp-mparam.h (BMOD_1_TO_MOD_1_THRESHOLD): Define.
diff --git a/doc/gmp.texi b/doc/gmp.texi
index 1c7c10b8c..896b85299 100644
--- a/doc/gmp.texi
+++ b/doc/gmp.texi
@@ -5379,9 +5379,10 @@ is not computed but can easily be obtained from @m{(G - US) / V, (@var{G} -
0} if and only if @math{V} divides @math{U} (i.e., @math{G = V}).
Store @math{G} at @var{gp} and let the return value define its limb count.
-Store @math{S} at @var{sp} and let |*@var{sn}| define its limb count. @math{S}
-can be negative; when this happens *@var{sn} will be negative. The areas at
-@var{gp} and @var{sp} should each have room for @var{vn} limbs.
+Store @math{S} at @var{sp} and let |*@var{sn}| define its limb count. @math{S}
+can be negative; when this happens *@var{sn} will be negative. The area at
+@var{gp} should have room for @var{vn} limbs and the area at @var{sp} should
+have room for @math{@var{vn}+1} limbs.
Both source operands are destroyed.
diff --git a/mpz/gcdext.c b/mpz/gcdext.c
index 9867a2eee..e718f5fe1 100644
--- a/mpz/gcdext.c
+++ b/mpz/gcdext.c
@@ -77,7 +77,7 @@ mpz_gcdext (mpz_ptr g, mpz_ptr s, mpz_ptr t, mpz_srcptr a, mpz_srcptr b)
MPN_COPY (tmp_bp, bp, bsize);
tmp_gp = TMP_ALLOC_LIMBS (bsize);
- tmp_sp = TMP_ALLOC_LIMBS (bsize);
+ tmp_sp = TMP_ALLOC_LIMBS (bsize + 1);
gsize = mpn_gcdext (tmp_gp, tmp_sp, &tmp_ssize, tmp_ap, asize, tmp_bp, bsize);