From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id BED9A3858438 for ; Wed, 2 Aug 2023 10:56:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org BED9A3858438 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1690973813; h=from:from:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references; bh=mZrJscU+f4Z8E+AfHMBwbcLiauPE3mDx5hK9ujDgupk=; b=i/YKEOmL7FGrMTZhaqWf8qVBmO+lsURQJM1SZDp7OA7TCuwDRDqKLpTtWdiKa5SywzZ0fW soUZP0zu4wFs11JmlgJu1ubVGnzex60OH20pWDYtmshJzAEAsneWn2f7/vjwscV2R6ecB5 STApyZ2H/JtBDZFTVC5uilYGB7WbJTA= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-479-zsmC_wmPMoCBFo42N_xncA-1; Wed, 02 Aug 2023 06:56:50 -0400 X-MC-Unique: zsmC_wmPMoCBFo42N_xncA-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A6517185A78B; Wed, 2 Aug 2023 10:56:48 +0000 (UTC) Received: from calimero.vinschen.de (unknown [10.39.193.241]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5C6BF492CA6; Wed, 2 Aug 2023 10:56:48 +0000 (UTC) Received: by calimero.vinschen.de (Postfix, from userid 500) id 113B7A80C36; Wed, 2 Aug 2023 12:56:47 +0200 (CEST) Date: Wed, 2 Aug 2023 12:56:47 +0200 From: Corinna Vinschen To: Takashi Yano Cc: newlib@sourceware.org, natan_b Subject: Re: [PATCH v2] newlib: Fix memory leak regarding gdtoa-based _ldtoa_r(). Message-ID: Reply-To: newlib@sourceware.org Mail-Followup-To: Takashi Yano , newlib@sourceware.org, natan_b References: <20230802063753.319-1-takashi.yano@nifty.ne.jp> MIME-Version: 1.0 In-Reply-To: <20230802063753.319-1-takashi.yano@nifty.ne.jp> X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Disposition: inline X-Spam-Status: No, score=-4.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Hi Takashi, On Aug 2 15:37, Takashi Yano wrote: > After the commit a4705d387f78, printf() for floating-point values > causes a memory leak. The legacy _ldtoa_r() assumed the char pointer > returned will be free'ed by Bfree(). However, gdtoa-based _ldtoa_r() > returns the pointer returned by gdtoa() which should be free'ed by > freedtoa(). Due to this issue, the caller of _ldtoa_r() fails to free > the allocated char buffer. This is the cause of the said memory leak. > https://cygwin.com/pipermail/cygwin/2023-July/254054.html > > This patch makes rv_alloc()/freedtoa() allocate/free the buffer in > a compatible way with legacy _ldtoa_r(). > > Fixes: a4705d387f78 ("ldtoa: Import gdtoa from OpenBSD.") > Reported-by: natan_b > Reviewed-by: Corinna Vinschen > Signed-off-by: Takashi Yano > --- > newlib/libc/stdlib/gdtoa-dmisc.c | 23 +++++++++++++---------- > newlib/libc/stdlib/gdtoa-ldtoa.c | 4 +--- > winsup/cygwin/release/3.4.8 | 3 +++ > 3 files changed, 17 insertions(+), 13 deletions(-) looks good to me, please push. Thanks, Corinna