diff -Naurd mpfr-4.1.0-a/PATCHES mpfr-4.1.0-b/PATCHES
--- mpfr-4.1.0-a/PATCHES	2021-02-11 12:43:51.761257868 +0000
+++ mpfr-4.1.0-b/PATCHES	2021-02-11 12:43:51.801257430 +0000
@@ -0,0 +1 @@
+random_deviate
diff -Naurd mpfr-4.1.0-a/VERSION mpfr-4.1.0-b/VERSION
--- mpfr-4.1.0-a/VERSION	2021-02-11 12:40:40.119363040 +0000
+++ mpfr-4.1.0-b/VERSION	2021-02-11 12:43:51.801257430 +0000
@@ -1 +1 @@
-4.1.0-p1
+4.1.0-p2
diff -Naurd mpfr-4.1.0-a/src/mpfr.h mpfr-4.1.0-b/src/mpfr.h
--- mpfr-4.1.0-a/src/mpfr.h	2021-02-11 12:40:40.115363084 +0000
+++ mpfr-4.1.0-b/src/mpfr.h	2021-02-11 12:43:51.801257430 +0000
@@ -27,7 +27,7 @@
 #define MPFR_VERSION_MAJOR 4
 #define MPFR_VERSION_MINOR 1
 #define MPFR_VERSION_PATCHLEVEL 0
-#define MPFR_VERSION_STRING "4.1.0-p1"
+#define MPFR_VERSION_STRING "4.1.0-p2"
 
 /* User macros:
    MPFR_USE_FILE:        Define it to make MPFR define functions dealing
diff -Naurd mpfr-4.1.0-a/src/random_deviate.c mpfr-4.1.0-b/src/random_deviate.c
--- mpfr-4.1.0-a/src/random_deviate.c	2020-01-08 18:11:13.000000000 +0000
+++ mpfr-4.1.0-b/src/random_deviate.c	2021-02-11 12:43:51.789257562 +0000
@@ -289,6 +289,7 @@
   mpfr_random_size_t p = mpfr_get_prec (z); /* Number of bits in result */
   mpz_t t;
   int inex;
+  mpfr_exp_t negxe;
 
   if (n == 0)
     {
@@ -370,14 +371,22 @@
   mpz_setbit (t, 0);     /* Set the trailing bit so result is always inexact */
   if (neg)
     mpz_neg (t, t);
-  /* Is -x->e representable as a mpfr_exp_t? */
-  MPFR_ASSERTN (x->e <= (mpfr_uexp_t)(-1) >> 1);
+  /* Portable version of the negation of x->e, with a check of overflow. */
+  if (MPFR_UNLIKELY (x->e > MPFR_EXP_MAX))
+    {
+      /* Overflow, except when x->e = MPFR_EXP_MAX + 1 = - MPFR_EXP_MIN. */
+      MPFR_ASSERTN (MPFR_EXP_MIN + MPFR_EXP_MAX == -1 &&
+                    x->e == (mpfr_random_size_t) MPFR_EXP_MAX + 1);
+      negxe = MPFR_EXP_MIN;
+    }
+  else
+    negxe = - (mpfr_exp_t) x->e;
   /*
    * Let mpfr_set_z_2exp do all the work of rounding to the requested
    * precision, setting overflow/underflow flags, and returning the right
    * inexact value.
    */
-  inex = mpfr_set_z_2exp (z, t, -x->e, rnd);
+  inex = mpfr_set_z_2exp (z, t, negxe, rnd);
   mpz_clear (t);
   return inex;
 }
diff -Naurd mpfr-4.1.0-a/src/version.c mpfr-4.1.0-b/src/version.c
--- mpfr-4.1.0-a/src/version.c	2021-02-11 12:40:40.119363040 +0000
+++ mpfr-4.1.0-b/src/version.c	2021-02-11 12:43:51.801257430 +0000
@@ -25,5 +25,5 @@
 const char *
 mpfr_get_version (void)
 {
-  return "4.1.0-p1";
+  return "4.1.0-p2";
 }
