summaryrefslogtreecommitdiff
path: root/mpz
diff options
context:
space:
mode:
authorMarco Bodrato <bodrato@mail.dm.unipi.it>2021-12-12 14:24:10 +0100
committerMarco Bodrato <bodrato@mail.dm.unipi.it>2021-12-12 14:24:10 +0100
commit650368f11361f45af429cac9690c9d85885d765c (patch)
tree06411f3152ec58173e1bd8fb0d6327f68ad3f78f /mpz
parent5ea34d9f6fd6ebe37653ea64dac820e05cb160d5 (diff)
downloadgmp-650368f11361f45af429cac9690c9d85885d765c.tar.gz
Handle overflow in mpz_type through errno.
Diffstat (limited to 'mpz')
-rw-r--r--mpz/init2.c7
-rw-r--r--mpz/realloc.c12
-rw-r--r--mpz/realloc2.c7
3 files changed, 7 insertions, 19 deletions
diff --git a/mpz/init2.c b/mpz/init2.c
index fcbaa66db..3133f60ab 100644
--- a/mpz/init2.c
+++ b/mpz/init2.c
@@ -1,6 +1,6 @@
/* mpz_init2 -- initialize mpz, with requested size in bits.
-Copyright 2001, 2002, 2008 Free Software Foundation, Inc.
+Copyright 2001, 2002, 2008, 2021 Free Software Foundation, Inc.
This file is part of the GNU MP Library.
@@ -43,10 +43,7 @@ mpz_init2 (mpz_ptr x, mp_bitcnt_t bits)
if (sizeof (unsigned long) > sizeof (int)) /* param vs _mp_size field */
{
if (UNLIKELY (new_alloc > INT_MAX))
- {
- fprintf (stderr, "gmp: overflow in mpz type\n");
- abort ();
- }
+ MPZ_OVERFLOW;
}
PTR(x) = __GMP_ALLOCATE_FUNC_LIMBS (new_alloc);
diff --git a/mpz/realloc.c b/mpz/realloc.c
index bb55bf683..184fdf8c9 100644
--- a/mpz/realloc.c
+++ b/mpz/realloc.c
@@ -1,6 +1,6 @@
/* _mpz_realloc -- make the mpz_t have NEW_ALLOC digits allocated.
-Copyright 1991, 1993-1995, 2000, 2001, 2008, 2015 Free Software
+Copyright 1991, 1993-1995, 2000, 2001, 2008, 2015, 2021 Free Software
Foundation, Inc.
This file is part of the GNU MP Library.
@@ -44,18 +44,12 @@ _mpz_realloc (mpz_ptr m, mp_size_t new_alloc)
if (sizeof (mp_size_t) == sizeof (int))
{
if (UNLIKELY (new_alloc > ULONG_MAX / GMP_NUMB_BITS))
- {
- fprintf (stderr, "gmp: overflow in mpz type\n");
- abort ();
- }
+ MPZ_OVERFLOW;
}
else
{
if (UNLIKELY (new_alloc > INT_MAX))
- {
- fprintf (stderr, "gmp: overflow in mpz type\n");
- abort ();
- }
+ MPZ_OVERFLOW;
}
if (ALLOC (m) == 0)
diff --git a/mpz/realloc2.c b/mpz/realloc2.c
index 535033942..9fa3a7578 100644
--- a/mpz/realloc2.c
+++ b/mpz/realloc2.c
@@ -1,6 +1,6 @@
/* mpz_realloc2 -- change allocated data size.
-Copyright 2001, 2002, 2008, 2015 Free Software Foundation, Inc.
+Copyright 2001, 2002, 2008, 2015, 2021 Free Software Foundation, Inc.
This file is part of the GNU MP Library.
@@ -43,10 +43,7 @@ mpz_realloc2 (mpz_ptr m, mp_bitcnt_t bits)
if (sizeof (unsigned long) > sizeof (int)) /* param vs _mp_size field */
{
if (UNLIKELY (new_alloc > INT_MAX))
- {
- fprintf (stderr, "gmp: overflow in mpz type\n");
- abort ();
- }
+ MPZ_OVERFLOW;
}
if (ALLOC (m) == 0)