From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10562 invoked by alias); 24 Mar 2004 15:25:18 -0000 Mailing-List: contact libc-hacker-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-hacker-owner@sources.redhat.com Received: (qmail 10542 invoked from network); 24 Mar 2004 15:25:16 -0000 Received: from unknown (HELO sunsite.ms.mff.cuni.cz) (195.113.15.26) by sources.redhat.com with SMTP; 24 Mar 2004 15:25:16 -0000 Received: from sunsite.ms.mff.cuni.cz (sunsite.mff.cuni.cz [127.0.0.1]) by sunsite.ms.mff.cuni.cz (8.12.8/8.12.8) with ESMTP id i2ODFVHS023929; Wed, 24 Mar 2004 14:15:31 +0100 Received: (from jakub@localhost) by sunsite.ms.mff.cuni.cz (8.12.8/8.12.8/Submit) id i2ODFVfi023925; Wed, 24 Mar 2004 14:15:31 +0100 Date: Wed, 24 Mar 2004 18:14:00 -0000 From: Jakub Jelinek To: Ulrich Drepper Cc: Glibc hackers Subject: [PATCH] Fix strtold Message-ID: <20040324131531.GK15946@sunsite.ms.mff.cuni.cz> Reply-To: Jakub Jelinek Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.4i X-SW-Source: 2004-03/txt/msg00129.txt.bz2 Hi! There were 2 bugs in strtold{,_l} if RETURN_LIMB_SIZE > 2 (e.g. IEEE quad long double on 32-bit architecture). 1) when clearing the rest of retval, it assumed there are at most 2 limbs 2) when shifting up by BITS_PER_MP_LIMB * empty bits, there was an off-by-one and no clearing of the bottom-most limbs 2004-03-24 Jakub Jelinek * stdlib/strtod_l.c (INTERNAL (__STRTOF)): Clear the rest of retval, not just one limb if RETURN_LIMB_SIZE > 2. Fix shifting up if RETURN_LIMB_SIZE > 2. --- libc/stdlib/strtod_l.c.jj 2004-03-24 13:45:24.000000000 -0500 +++ libc/stdlib/strtod_l.c 2004-03-24 14:14:18.000000000 -0500 @@ -1159,7 +1159,11 @@ INTERNAL (__STRTOF) (nptr, endptr, group memcpy (retval, num, numsize * sizeof (mp_limb_t)); #if RETURN_LIMB_SIZE > 1 if (numsize < RETURN_LIMB_SIZE) +# if RETURN_LIMB_SIZE == 2 retval[numsize] = 0; +# else + MPN_ZERO (retval + numsize, RETURN_LIMB_SIZE - numsize); +# endif #endif } @@ -1465,8 +1469,10 @@ INTERNAL (__STRTOF) (nptr, endptr, group __mpn_lshift_1 (retval, RETURN_LIMB_SIZE, BITS_PER_MP_LIMB, 0); #else - for (i = RETURN_LIMB_SIZE; i > empty; --i) + for (i = RETURN_LIMB_SIZE - 1; i >= empty; --i) retval[i] = retval[i - empty]; + while (i >= 0) + retval[i--] = 0; #endif for (i = numsize; i > 0; --i) num[i + empty] = num[i - 1]; Jakub