[Gmp-commit] /var/hg/gmp: (mpn_dc_set_str): Work around a valgrind issue.

mercurial at gmplib.org mercurial at gmplib.org
Wed Dec 5 19:20:42 CET 2012


details:   /var/hg/gmp/rev/88686f17a247
changeset: 15160:88686f17a247
user:      Torbjorn Granlund <tege at gmplib.org>
date:      Wed Dec 05 19:20:37 2012 +0100
description:
(mpn_dc_set_str): Work around a valgrind issue.

diffstat:

 ChangeLog             |  2 ++
 mpn/generic/set_str.c |  4 +++-
 2 files changed, 5 insertions(+), 1 deletions(-)

diffs (25 lines):

diff -r 406e8bebd91d -r 88686f17a247 ChangeLog
--- a/ChangeLog	Wed Dec 05 17:34:09 2012 +0100
+++ b/ChangeLog	Wed Dec 05 19:20:37 2012 +0100
@@ -1,5 +1,7 @@
 2012-12-05  Torbjorn Granlund  <tege at gmplib.org>
 
+	* mpn/generic/set_str.c (mpn_dc_set_str): Work around a valgrind issue.
+
 	* mpz/powm_ui.c: Don't assume >= 2 limbs in mod argument.
 
 	* tests/tests.h (TESTS_REPS): Handle float GMP_CHECK_REPFACTOR.
diff -r 406e8bebd91d -r 88686f17a247 mpn/generic/set_str.c
--- a/mpn/generic/set_str.c	Wed Dec 05 17:34:09 2012 +0100
+++ b/mpn/generic/set_str.c	Wed Dec 05 19:20:37 2012 +0100
@@ -238,7 +238,9 @@
 
   if (hn == 0)
     {
-      MPN_ZERO (rp, powtab->n + sn);
+      /* Zero +1 limb here, to avoid reading an allocated but uninitialised
+	 limb in mpn_incr_u below.  */
+      MPN_ZERO (rp, powtab->n + sn + 1);
     }
   else
     {


More information about the gmp-commit mailing list