From 1b14c8bfbdd53b0d723a73e16b0ce0dc449cf9f5 Mon Sep 17 00:00:00 2001 From: Marco Bodrato Date: Sun, 25 Oct 2020 17:19:53 +0100 Subject: mini-gmp.c (mpz_out_str): Return 0 when base is out of range (spotted by Paul Eggert) --- mini-gmp/mini-gmp.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'mini-gmp') 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); -- cgit v1.2.1