diff options
author | Marco Bodrato <bodrato@mail.dm.unipi.it> | 2020-10-25 17:19:53 +0100 |
---|---|---|
committer | Marco Bodrato <bodrato@mail.dm.unipi.it> | 2020-10-25 17:19:53 +0100 |
commit | 1b14c8bfbdd53b0d723a73e16b0ce0dc449cf9f5 (patch) | |
tree | 7f8a0e558c9aa0f15ff22afa7e20bd33657edc7c /mini-gmp | |
parent | 0a9bb1eefef31436919eb93001f06141770d0d43 (diff) | |
download | gmp-1b14c8bfbdd53b0d723a73e16b0ce0dc449cf9f5.tar.gz |
mini-gmp.c (mpz_out_str): Return 0 when base is out of range (spotted by Paul Eggert)
Diffstat (limited to 'mini-gmp')
-rw-r--r-- | mini-gmp/mini-gmp.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/mini-gmp/mini-gmp.c b/mini-gmp/mini-gmp.c index 65735d98a..c8e69681e 100644 --- a/mini-gmp/mini-gmp.c +++ b/mini-gmp/mini-gmp.c @@ -32,7 +32,7 @@ see https://www.gnu.org/licenses/. */ /* NOTE: All functions in this file which are not declared in mini-gmp.h are internal, and are not intended to be compatible - neither with GMP nor with future versions of mini-gmp. */ + with GMP or with future versions of mini-gmp. */ /* Much of the material copied from GMP files, including: gmp-impl.h, longlong.h, mpn/generic/add_n.c, mpn/generic/addmul_1.c, @@ -4423,6 +4423,8 @@ mpz_out_str (FILE *stream, int base, const mpz_t x) size_t len, n; str = mpz_get_str (NULL, base, x); + if (!str) + return 0; len = strlen (str); n = fwrite (str, 1, len, stream); gmp_free (str, len + 1); |